On Nov 10, 2016, at 4:16 PM, Christos Zoulas <christos@zoulas.com> wrote:
On Nov 10, 6:17pm, tgl@sss.pgh.pa.us (Tom Lane) wrote: -- Subject: Re: [tz] NetBSD vs Darwin timezone API (was: tzdata2016g missing
| Also ... what will you do for localtime() wherein there's no explicit | initialization call whereby callers could say which behavior they want?
Nothing happens to that. If you use localtime() you don't get autoupdates. We could add a new call tzsetflags(int flags); to turn this on for the statically allocated global timezone... I am not sure if this is a good idea or not. I guess Darwin is doing it?
Yes. If you compile and run this program: #include <stdio.h> #include <time.h> #include <unistd.h> int main(void) { time_t now; for (;;) { now = time(NULL); printf("%s", ctime(&now)); sleep(5); } return 0; } and then go into the "Time Zone" pane of the "Date & Time" page of System Preferences and change your system's time zone, and wait for the next time printout, the next printout will reflect the local time in *that* zone, *not* the zone that was in effect when the program was started - and the same will happen for the next change, etc.. (I just tested this a few minutes ago.) It'll probably happen if you stick with "Set time zone automatically using current location", and take the machine across a tzdb zone boundary where the current offset from UTC changes; I'm too far from such a boundary to test it right now. :-)