diff options
| author | Paul Eggert | 2020-01-24 13:36:56 -0800 |
|---|---|---|
| committer | Paul Eggert | 2020-01-24 13:41:56 -0800 |
| commit | a391ffa2f0377306449b36cc62858db823d2e990 (patch) | |
| tree | 6b4c1723452ea8ec3ce456278f964626df209275 /lisp | |
| parent | 9c576c207a8f4f98fd89deb4f3b4bfbe1ad37e37 (diff) | |
| download | emacs-a391ffa2f0377306449b36cc62858db823d2e990.tar.gz emacs-a391ffa2f0377306449b36cc62858db823d2e990.zip | |
Fix iso8601-parse so unknown DST is -1, not nil
The convention in a decoded time’s dst flag is that t means DST,
nil means standard time, and -1 means unknown. This differs from
the convention for other components of a decoded time, where nil
means unknown. Fix some places where iso8601-parse mistakenly
treated nil as meaning that the dst flag was unknown.
* doc/lispref/os.texi (Time Parsing):
Adjust to match parse-time-string’s doc string.
* lisp/calendar/iso8601.el (iso8601-parse):
Set dst flag to nil if a numeric time zone or "Z" is given.
(iso8601--decoded-time): Default dst flag to -1 if no dst
flag or zone is given.
* lisp/calendar/time-date.el (decoded-time-set-defaults):
When we don’t have a time zone, set the dst flag consistently
with DEFAULT-ZONE.
* test/lisp/calendar/iso8601-tests.el (test-iso8601-date-years)
(test-iso8601-date-dates, test-iso8601-date-obsolete)
(test-iso8601-date-weeks, test-iso8601-date-ordinals)
(test-iso8601-time, test-iso8601-combined)
(test-iso8601-duration, test-iso8601-intervals)
(standard-test-dates, standard-test-time-of-day-local-time)
(standard-test-time-of-day-fractions)
(nonstandard-test-time-of-day-decimals)
(standard-test-time-of-day-beginning-of-day)
(standard-test-date-and-time-of-day, standard-test-interval):
Adjust tests to match fixed behavior.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/calendar/iso8601.el | 8 | ||||
| -rw-r--r-- | lisp/calendar/time-date.el | 17 |
2 files changed, 14 insertions, 11 deletions
diff --git a/lisp/calendar/iso8601.el b/lisp/calendar/iso8601.el index ae1dab17252..e42fe0fa21f 100644 --- a/lisp/calendar/iso8601.el +++ b/lisp/calendar/iso8601.el | |||
| @@ -136,7 +136,8 @@ See `decode-time' for the meaning of FORM." | |||
| 136 | (when zone-string | 136 | (when zone-string |
| 137 | (setf (decoded-time-zone date) | 137 | (setf (decoded-time-zone date) |
| 138 | ;; The time zone in decoded times are in seconds. | 138 | ;; The time zone in decoded times are in seconds. |
| 139 | (* (iso8601-parse-zone zone-string) 60))) | 139 | (* (iso8601-parse-zone zone-string) 60)) |
| 140 | (setf (decoded-time-dst date) nil)) | ||
| 140 | date))) | 141 | date))) |
| 141 | 142 | ||
| 142 | (defun iso8601-parse-date (string) | 143 | (defun iso8601-parse-date (string) |
| @@ -332,6 +333,9 @@ Return the number of minutes." | |||
| 332 | (list start end | 333 | (list start end |
| 333 | (or duration | 334 | (or duration |
| 334 | ;; FIXME: Support subseconds. | 335 | ;; FIXME: Support subseconds. |
| 336 | ;; FIXME: It makes no sense to decode a time difference | ||
| 337 | ;; according to (decoded-time-zone end), or according to | ||
| 338 | ;; any other time zone for that matter. | ||
| 335 | (decode-time (time-subtract (iso8601--encode-time end) | 339 | (decode-time (time-subtract (iso8601--encode-time end) |
| 336 | (iso8601--encode-time start)) | 340 | (iso8601--encode-time start)) |
| 337 | (or (decoded-time-zone end) 0) 'integer))))) | 341 | (or (decoded-time-zone end) 0) 'integer))))) |
| @@ -354,7 +358,7 @@ Return the number of minutes." | |||
| 354 | (iso8601--value month) | 358 | (iso8601--value month) |
| 355 | (iso8601--value year) | 359 | (iso8601--value year) |
| 356 | nil | 360 | nil |
| 357 | dst | 361 | (if (or dst zone) dst -1) |
| 358 | zone)) | 362 | zone)) |
| 359 | 363 | ||
| 360 | (defun iso8601--encode-time (time) | 364 | (defun iso8601--encode-time (time) |
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index 1e589ece29d..e2402de8010 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el | |||
| @@ -515,15 +515,14 @@ TIME is modified and returned." | |||
| 515 | (unless (decoded-time-year time) | 515 | (unless (decoded-time-year time) |
| 516 | (setf (decoded-time-year time) 0)) | 516 | (setf (decoded-time-year time) 0)) |
| 517 | 517 | ||
| 518 | ;; When we don't have a time zone and we don't have a DST, then mark | 518 | ;; When we don't have a time zone, default to DEFAULT-ZONE without |
| 519 | ;; it as unknown. | 519 | ;; DST if DEFAULT-ZONE if given, and to unknown DST otherwise. |
| 520 | (when (and (not (decoded-time-zone time)) | 520 | (unless (decoded-time-zone time) |
| 521 | (not (decoded-time-dst time))) | 521 | (if default-zone |
| 522 | (setf (decoded-time-dst time) -1)) | 522 | (progn (setf (decoded-time-zone time) default-zone) |
| 523 | 523 | (setf (decoded-time-dst time) nil)) | |
| 524 | (when (and (not (decoded-time-zone time)) | 524 | (setf (decoded-time-dst time) -1))) |
| 525 | default-zone) | 525 | |
| 526 | (setf (decoded-time-zone time) 0)) | ||
| 527 | time) | 526 | time) |
| 528 | 527 | ||
| 529 | (provide 'time-date) | 528 | (provide 'time-date) |