Open MFAshby opened 2 years ago
Having dug into this a bit, it seems like generally there's two function calls required to get a time with a timezone:
time_t t = time(NULL);
localtime_r(&t, &tm);
strftime(buf, BUFSIZ, example_format, &tm);
printf("%s\n", buf);
so it'd be necessary for libfaketime to hook into localtime(_r) and friends in order to fake the current system time zone. It would also be necessary to somehow supply a fake value for /etc/localtime, since some applications look at that rather than using libc's localtime (postgres, for example). Hm.
I'm working around this for now by simply converting to UTC before writing to /etc/faketimerc, which is fine.
Not sure whether hooking into localtime
is necessary here. Have you tried replacing libfaketime's use of mktime
with timegm
?
This issue was already raised, but closed: https://github.com/wolfcw/libfaketime/issues/175
It seems that the timezone is lost when setting the fake date & time. Example script:
I'm running arch linux, I'll try a couple of other platforms if I can. Note that strptime behaves as expected on my system: the following C program checks it