Closed dumblob closed 9 years ago
I'd rather avoid that solution you mentioned: messing with environment variables is slow and may accidentally affect other threads (non-Dao-based) which rely on C's time functions.
This one is fast, portable and we should use it (it's Public domain, which is forbidden in Europe, but you can take over the authorship, so then it's not an issue in Europe any more - Red Hat does it exactly this way with Public domain :wink:): http://www.catb.org/esr/time-programming/#_mktime_3_timelocal_3_timegm_3 .
Portability (and especially regarding time
) should be much more important for us then speed (at least for the time being).
Or alternatively similar implementation http://stackoverflow.com/questions/16647819/timegm-cross-platform .
OK, I added the TZ-way for platforms where timegm()
may be unavailable.
Ok, good. As it's impossible to have a really portable solution here (because as it's said in several other implementations of timegm()
, it's impossible to construct a correct algorithm using only POSIX-compliant interface), the TZ-solution is acceptable.
In
time/dao_time.c
theDaoMkTimeUtc()
is implemented on UNIX usingtimegm()
, but it's a GNU extension (i.e. not POSIX) and also it's not recommended to use it - I'd use the solution described in Notes on the linked manual page.