Commit 325f51c8 authored by Paul Eggert's avatar Paul Eggert
Browse files

Fix decode-time/encode-time roundtrip on macOS

* src/timefns.c (Fencode_time): Ignore DST flag when the zone is
numeric or is a cons, as the doc string says it’s ignored in that
case, and not ignoring it causes encode-time to not invert
decode-time on some platforms (Bug#35502).
* test/src/timefns-tests.el (encode-time-dst-numeric-zone):
New test.
parent 35ef33dd
Pipeline #1509 passed with stage
in 64 minutes and 38 seconds
...@@ -1488,10 +1488,11 @@ usage: (encode-time &optional TIME FORM &rest OBSOLESCENT-ARGUMENTS) */) ...@@ -1488,10 +1488,11 @@ usage: (encode-time &optional TIME FORM &rest OBSOLESCENT-ARGUMENTS) */)
tm.tm_mon = check_tm_member (XCAR (a), 1); a = XCDR (a); tm.tm_mon = check_tm_member (XCAR (a), 1); a = XCDR (a);
tm.tm_year = check_tm_member (XCAR (a), TM_YEAR_BASE); a = XCDR (a); tm.tm_year = check_tm_member (XCAR (a), TM_YEAR_BASE); a = XCDR (a);
a = XCDR (a); a = XCDR (a);
if (SYMBOLP (XCAR (a))) Lisp_Object dstflag = XCAR (a);
tm.tm_isdst = !NILP (XCAR (a));
a = XCDR (a); a = XCDR (a);
zone = XCAR (a); zone = XCAR (a);
if (SYMBOLP (dstflag) && !FIXNUMP (zone) && !CONSP (zone))
tm.tm_isdst = !NILP (dstflag);
} }
else if (nargs < 6) else if (nargs < 6)
xsignal2 (Qwrong_number_of_arguments, Qencode_time, make_fixnum (nargs)); xsignal2 (Qwrong_number_of_arguments, Qencode_time, make_fixnum (nargs));
......
...@@ -142,3 +142,9 @@ ...@@ -142,3 +142,9 @@
(< 0.99 (/ x y) 1.01) (< 0.99 (/ x y) 1.01)
(< 0.99 (/ (- (float-time a)) (float-time b)) (< 0.99 (/ (- (float-time a)) (float-time b))
1.01)))))))) 1.01))))))))
(ert-deftest encode-time-dst-numeric-zone ()
"Check for Bug#35502."
(should (time-equal-p
(encode-time '(29 31 17 30 4 2019 2 t 7200))
'(23752 27217))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment