- Fix use of "clever" mktime.

-  Fix support for leap seconds-aware timezones.

from piotr sikora
This commit is contained in:
jasper 2012-07-18 13:44:31 +00:00
parent e36ebe3043
commit 91d743a84d
2 changed files with 52 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.49 2012/06/22 13:08:09 phessler Exp $
# $OpenBSD: Makefile,v 1.50 2012/07/18 13:44:31 jasper Exp $
COMMENT= real-time, concurrent and distributed functional language
BROKEN-sparc= Requires v9|v9a|v9b; requested architecture is sparclite.
@ -7,6 +7,7 @@ V= R15B01
DISTNAME= otp_src_${V}
PKGNAME= erlang-15b.01
EPOCH= 0
REVISION= 0
CATEGORIES= lang
# Erlang Public License

View File

@ -0,0 +1,50 @@
$OpenBSD: patch-erts_emulator_beam_erl_time_sup_c,v 1.3 2012/07/18 13:44:31 jasper Exp $
[PATCH] Fix use of "clever" mktime.
Commit 1eef765 introduced regression (conditional _always_ evaluates
to true) in which erlang:localtime_to_universaltime/2 stopped working
on systems configured with timezone without DST (i.e. UTC) on *BSD
platforms:
1> erlang:localtime_to_universaltime({{2012,1,1},{0,0,0}}, true).
** exception error: bad argument
[PATCH] 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}}).
[]
--- erts/emulator/beam/erl_time_sup.c.orig Sun Apr 1 18:14:36 2012
+++ erts/emulator/beam/erl_time_sup.c Fri Jul 13 05:52:50 2012
@@ -757,7 +757,7 @@
refuses to give us a DST time, we simulate the Linux/Solaris
behaviour of giving the same data as if is_dst was not set. */
t.tm_isdst = 0;
- if (erl_mktime(&the_clock, &t)) {
+ if (erl_mktime(&the_clock, &t) < 0) {
/* Failed anyway, something else is bad - will be a badarg */
return 0;
}
@@ -766,6 +766,9 @@
return 0;
}
}
+
+ the_clock = time2posix(the_clock);
+
#ifdef HAVE_GMTIME_R
tm = gmtime_r(&the_clock, &tmbuf);
#else