aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_time_sup.c
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2011-12-06 19:07:40 +0100
committerBjörn-Egil Dahlberg <[email protected]>2011-12-08 14:12:03 +0100
commit46eb4359b05b220861453a869dc734480ec045a6 (patch)
tree0d9601c7c7637eed9f941a89748c3d1577ba7ef9 /erts/emulator/beam/erl_time_sup.c
parent965db6494f80e4c784aa3bb1cd96dd925ce8b284 (diff)
downloadotp-46eb4359b05b220861453a869dc734480ec045a6.tar.gz
otp-46eb4359b05b220861453a869dc734480ec045a6.tar.bz2
otp-46eb4359b05b220861453a869dc734480ec045a6.zip
Emulate localtime, gmtime and mktime to enable negative time_t
Diffstat (limited to 'erts/emulator/beam/erl_time_sup.c')
-rw-r--r--erts/emulator/beam/erl_time_sup.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/erts/emulator/beam/erl_time_sup.c b/erts/emulator/beam/erl_time_sup.c
index 54d732000b..53a2ba456b 100644
--- a/erts/emulator/beam/erl_time_sup.c
+++ b/erts/emulator/beam/erl_time_sup.c
@@ -491,7 +491,7 @@ get_time(int *hour, int *minute, int *second)
the_clock = time((time_t *)0);
#ifdef HAVE_LOCALTIME_R
- localtime_r(&the_clock, (tm = &tmbuf));
+ tm = localtime_r(&the_clock, &tmbuf);
#else
tm = localtime(&the_clock);
#endif
@@ -513,7 +513,7 @@ get_date(int *year, int *month, int *day)
the_clock = time((time_t *)0);
#ifdef HAVE_LOCALTIME_R
- localtime_r(&the_clock, (tm = &tmbuf));
+ tm = localtime_r(&the_clock, &tmbuf);
#else
tm = localtime(&the_clock);
#endif
@@ -762,10 +762,13 @@ local_to_univ(Sint *year, Sint *month, Sint *day,
}
}
#ifdef HAVE_GMTIME_R
- gmtime_r(&the_clock, (tm = &tmbuf));
+ tm = gmtime_r(&the_clock, &tmbuf);
#else
tm = gmtime(&the_clock);
#endif
+ if (!tm) {
+ return 0;
+ }
*year = tm->tm_year + 1900;
*month = tm->tm_mon +1;
*day = tm->tm_mday;