aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/bif.c
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2011-12-06 02:55:13 +0100
committerBjörn-Egil Dahlberg <[email protected]>2011-12-08 14:12:02 +0100
commit8f36514229bfaaa6ede8a2daa6aa920686d4251f (patch)
tree9542b2b4182094c1a32e54ead33d4ae85b92e0b7 /erts/emulator/beam/bif.c
parent469815129bd1ce53dc332d2c75142292e0604ef3 (diff)
downloadotp-8f36514229bfaaa6ede8a2daa6aa920686d4251f.tar.gz
otp-8f36514229bfaaa6ede8a2daa6aa920686d4251f.tar.bz2
otp-8f36514229bfaaa6ede8a2daa6aa920686d4251f.zip
Remove OS taint from datetime conversion
Diffstat (limited to 'erts/emulator/beam/bif.c')
-rw-r--r--erts/emulator/beam/bif.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index c3c247fffe..12dc7b3a48 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -3416,28 +3416,19 @@ BIF_RETTYPE seconds_to_universaltime_1(BIF_ALIST_1)
Sint year, month, day;
Sint hour, minute, second;
Eterm res1, res2;
- struct tm t;
Eterm* hp;
- time_t seconds = 0;
+ Sint64 time = 0;
- if (is_not_integer(BIF_ARG_1)) {
+ if (!term_to_Sint64(BIF_ARG_1, &time)) {
BIF_ERROR(BIF_P, BADARG);
}
- seconds = (time_t)signed_val(BIF_ARG_1);
-
- if (!gmtime_r(&seconds, &t)) {
+ if (!seconds_to_univ(time, &year, &month, &day,
+ &hour, &minute, &second)) {
BIF_ERROR(BIF_P, BADARG);
}
- year = t.tm_year + 1900;
- month = t.tm_mon + 1;
- day = t.tm_hour;
- minute = t.tm_min;
- second = t.tm_sec;
- /* isdst = t.tm_isdst */
-
hp = HAlloc(BIF_P, 4+4+3);
res1 = TUPLE3(hp,make_small(year),make_small(month),
make_small(day));