dev/c/datetime_test/datetime_test.c

64 lines
925 B
C
Raw Normal View History

#include <time.h>
#include <string.h>
#include <stdio.h>
#include "datetime.h"
2011-12-09 17:09:36 +04:00
void tz_test()
{
struct tm tm;
time_t tt;
char buf[64];
tm.tm_year = 2011 - 1900;
tm.tm_mon = 12 - 1;
tm.tm_mday = 9;
tm.tm_hour = 15;
tm.tm_min = 15;
tm.tm_sec = 52;
2011-12-09 15:30:17 +04:00
tm.tm_isdst = 0;
2011-12-09 15:30:17 +04:00
tt = mktime(&tm) - timezone;
memset(&tm, 0, sizeof(tm));
tm = *gmtime(&tt);
strftime(buf, sizeof(buf), "%Y.%m.%d %H.%M.%S", &tm);
puts(buf);
2011-12-09 17:09:36 +04:00
}
void cs_test()
{
struct datetime_cs dtcs;
time_t tt;
char buf[64];
dtcs.tm.tm_year = 2011 - 1900;
dtcs.tm.tm_mon = 12 - 1;
dtcs.tm.tm_mday = 9;
dtcs.tm.tm_hour = 15;
dtcs.tm.tm_min = 15;
dtcs.tm.tm_sec = 52;
dtcs.tm.tm_isdst = 0;
tt = mktime(&dtcs.tm) - timezone;
memset(&dtcs.tm, 0, sizeof(dtcs.tm));
dtcs.tm = *gmtime(&tt);
strftime(buf, sizeof(buf), "%Y.%m.%d %H.%M.%S", &dtcs.tm);
puts(buf);
}
int main(int argc, char *argv[])
{
//tz_test();
cs_test();
return 0;
}