Date: Fri, 7 Aug 2009 10:34:56 -0700 From: "Peter Steele" <psteele@webmail.maxiscale.com> To: <freebsd-questions@freebsd.org> Subject: RE: How is time zone change signalled? Message-ID: <B8A480488C0C6849826655761349EA431F7146@owa.webmail.maxiscale.com> References: <B8A480488C0C6849826655761349EA431F713D@owa.webmail.maxiscale.com> <4A7C4007.9000506@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
>Did you try unsetting TZ and then calling tzset()? The man page implies that doing so will force a reread of /etc/localtime >(http://www.freebsd.org/cgi/man.cgi?query=3Dtzset&sourceid=3Dopensearch)= : > >"The tzset() function initializes time conversion information used by the library routine localtime(3). The environment variable TZ specifies how this is done. > >If TZ does not appear in the environment, the best available approximation to local wall clock time, as specified by the tzfile(5)-format file /etc/localtime is used." > >I haven't tested it, though, and I'm no timezone expert, so I may be completely off-base! Yes, I've tried the tzset function. I'm basically doing the equivalent of these steps after the Java app changes time zone and updates /etc/localtime: time_t date =3D time(NULL); unsetenv("TZ"); tzset(); printf("time zone is %s/%s", tzname[0], tzname[1]); struct tm* locTime =3D localtime(&date); printf("%02d:%02d:%02d", locTime->tm_hour, locTime->tm_min, locTime->tm_sec); The time printed is still based on the old time zone though. The tzname variable that is set by tzset() still shows for example EDT even if I have just changed the time zone to PDT. If I stop and restart the C app, the time is correct, and tzname is then PDT instead of EDT. I'm very puzzled on what I'm supposed to do to kick start the C time zone. We do not want to have to restart our C apps for something as trivial as this.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B8A480488C0C6849826655761349EA431F7146>