c - _tzset and x letter time-zone names -
how can set, in c, time zone saint pierre , miquelon (pmst3pmdt) format:
set tz=tzn[+ | –]hh[:mm[:ss] ][dzn]
if @ documentation of _tzset, can read that:
tzn
three-letter time-zone name, such pst. must specify correct offset local time utc.
what time zone names of 4 letters (pmdt) or 5 letters (easst) ? here list of time zone abbreviations: wikiepedia
here simple code in c test _tzset:
#include <stdio.h> #include <stdlib.h> #include <sys/timeb.h> #include <time.h> //add _crt_secure_no_warnings in project properties "preprocessor definitions" int main(int argc, char* argv[]) { time_t t; struct tm * now; _putenv("tz=pst8pdt"); // pacific standard time, there no problem _tzset(); t = time(0); = localtime( & t ); printf("time: %d:%d \nisdst:%d\n", now->tm_hour, now->tm_min, now->tm_isdst); printf("_daylight=%d\n", _daylight); printf( "_timezone=%d\n", _timezone); printf( "_tzname[0]=%s\n", _tzname[0]); printf( "_tzname[1]=%s\n", _tzname[1]); return 0; }
*i'm using windows8, visual studio 2012
from see in timezone database on ubuntu:
/usr/share/zoneinfo/zone.tab
the timezone want use named america/miquelon
.
so want this:
setenv("tz", "america/miquelon", 1); tzset();
to force timezone saint pierre & miquelon.
i not know whether work under ms-windows though...
Comments
Post a Comment