diff options
author | Piotr Sikora <[email protected]> | 2012-07-14 04:38:13 +0000 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2012-08-01 10:01:29 +0200 |
commit | 904384397517ded1e9d2e3b1c6fdf16eeb2dab67 (patch) | |
tree | e25a8f5a4eb522b1e652633fb6f066045797dbfc /erts/emulator/beam/erl_time_sup.c | |
parent | ffcdf6f983bd9b7005abc2e69c4a0f187b8493f6 (diff) | |
download | otp-904384397517ded1e9d2e3b1c6fdf16eeb2dab67.tar.gz otp-904384397517ded1e9d2e3b1c6fdf16eeb2dab67.tar.bz2 otp-904384397517ded1e9d2e3b1c6fdf16eeb2dab67.zip |
Fix support for leap seconds-aware timezones
erlang:universaltime_to_localtime is leap seconds-aware (since 2008),
however erlang:localtime_to_universaltime is not, which gives
surprising results on systems configured with leap seconds-aware
timezones:
1> erlang:universaltime_to_localtime({{2012,1,1},{0,0,0}}).
{{2012,1,1},{0,0,0}}
2> erlang:localtime_to_universaltime({{2012,1,1},{0,0,0}}).
{{2012,1,1},{0,0,24}}
and completely breaks calendar:local_time_to_universal_time_dst:
3> calendar:local_time_to_universal_time_dst({{2011,1,1},{0,0,0}}).
[]
Signed-off-by: Piotr Sikora <[email protected]>
Diffstat (limited to 'erts/emulator/beam/erl_time_sup.c')
-rw-r--r-- | erts/emulator/beam/erl_time_sup.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_time_sup.c b/erts/emulator/beam/erl_time_sup.c index 1d0735aa99..4a04103652 100644 --- a/erts/emulator/beam/erl_time_sup.c +++ b/erts/emulator/beam/erl_time_sup.c @@ -717,6 +717,11 @@ int univ_to_seconds(Sint year, Sint month, Sint day, Sint hour, Sint minute, Sin return 1; } +#if defined(HAVE_TIME2POSIX) && defined(HAVE_DECL_TIME2POSIX) && \ + !HAVE_DECL_TIME2POSIX +extern time_t time2posix(time_t); +#endif + int local_to_univ(Sint *year, Sint *month, Sint *day, Sint *hour, Sint *minute, Sint *second, int isdst) @@ -766,6 +771,11 @@ local_to_univ(Sint *year, Sint *month, Sint *day, return 0; } } + +#ifdef HAVE_TIME2POSIX + the_clock = time2posix(the_clock); +#endif + #ifdef HAVE_GMTIME_R tm = gmtime_r(&the_clock, &tmbuf); #else |