Fix failing tests in non-daylight saving time zones
* lisp/org.el (org-time-string-to-time): Remove optional POS and BUFFER arguments. Accept new optional ZONE argument. (org-time-string-to-seconds): Accept optional ZONE argument. (org-check-before-date): (org-check-after-date): (org-check-dates-range): (org-goto-calendar): * lisp/ob-gnuplot.el (org-time-string-to-time): * lisp/org-agenda.el (org-agenda-get-blocks): * lisp/org-clock.el (org-clock-timestamps-change): * lisp/org-list.el (org-time-string-to-seconds): Use UTC for time difference and time comparison. * testing/lisp/test-org-clock.el (org-test-clock-create-clock): Use UTC for time differences.
This commit is contained in:
parent
fd6a6b5cb4
commit
97a1a49895
|
@ -23,7 +23,7 @@ Consider setting ~org-duration-units~ instead.
|
|||
|
||||
*** ~org-at-timestamp-p~ optional argument accepts different values
|
||||
|
||||
See docustrings for the allowed values. For backward compatibility,
|
||||
See docstrings for the allowed values. For backward compatibility,
|
||||
~(org-at-timestamp-p t)~ is still supported, but should be updated
|
||||
accordingly.
|
||||
|
||||
|
@ -85,6 +85,8 @@ list as their first argument.
|
|||
The optional argument is now a string to extract the repeater from.
|
||||
See docstring for details.
|
||||
|
||||
*** Change signature for ~org-time-string-to-time~
|
||||
See docstring for changes.
|
||||
** New features
|
||||
*** New Org duration library
|
||||
This new library implements tools to read and print time durations in
|
||||
|
@ -392,6 +394,7 @@ suitable as a default value.
|
|||
*** New entities : ~\dollar~ and ~\USD~
|
||||
*** ~org-parse-time-string~ accepts a new optional argument
|
||||
=ZONE= specifies the current time zone.
|
||||
*** ~org-time-string-to-seconds~ now accepts an optional =ZONE= argument
|
||||
*** Support for date style URLs in =org-protocol://open-source=
|
||||
URLs like =https://cool-blog.com/2017/05/20/cool-post/= are
|
||||
covered by rewrite rules.
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(declare-function org-time-string-to-time "org" (s &optional buffer pos))
|
||||
(declare-function org-time-string-to-time "org" (s &optional zone))
|
||||
(declare-function org-combine-plists "org" (&rest plists))
|
||||
(declare-function orgtbl-to-generic "org-table" (table params))
|
||||
(declare-function gnuplot-mode "ext:gnuplot-mode" ())
|
||||
|
|
|
@ -6264,8 +6264,26 @@ scheduled items with an hour specification like [h]h:mm."
|
|||
(end-time (match-string 2)))
|
||||
(setq s1 (match-string 1)
|
||||
s2 (match-string 2)
|
||||
d1 (time-to-days (org-time-string-to-time s1 (current-buffer) pos))
|
||||
d2 (time-to-days (org-time-string-to-time s2 (current-buffer) pos)))
|
||||
d1 (time-to-days
|
||||
(condition-case err
|
||||
(org-time-string-to-time s1)
|
||||
(error
|
||||
(error
|
||||
"Bad timestamp %S at %d in buffer %S\nError was: %s"
|
||||
s1
|
||||
pos
|
||||
(current-buffer)
|
||||
(error-message-string err)))))
|
||||
d2 (time-to-days
|
||||
(condition-case err
|
||||
(org-time-string-to-time s2)
|
||||
(error
|
||||
(error
|
||||
"Bad timestamp %S at %d in buffer %S\nError was: %s"
|
||||
s2
|
||||
pos
|
||||
(current-buffer)
|
||||
(error-message-string err))))))
|
||||
(if (and (> (- d0 d1) -1) (> (- d2 d0) -1))
|
||||
;; Only allow days between the limits, because the normal
|
||||
;; date stamps will catch the limits.
|
||||
|
|
|
@ -1701,8 +1701,8 @@ Optional argument N tells to change by that many units."
|
|||
(begts (if updatets1 begts1 begts2)))
|
||||
(setq tdiff
|
||||
(time-subtract
|
||||
(org-time-string-to-time org-last-changed-timestamp)
|
||||
(org-time-string-to-time ts)))
|
||||
(org-time-string-to-time org-last-changed-timestamp t)
|
||||
(org-time-string-to-time ts t)))
|
||||
(save-excursion
|
||||
(goto-char begts)
|
||||
(org-timestamp-change
|
||||
|
|
|
@ -149,7 +149,7 @@
|
|||
(declare-function org-remove-indentation "org" (code &optional n))
|
||||
(declare-function org-show-subtree "org" ())
|
||||
(declare-function org-sort-remove-invisible "org" (S))
|
||||
(declare-function org-time-string-to-seconds "org" (s))
|
||||
(declare-function org-time-string-to-seconds "org" (s &optional zone))
|
||||
(declare-function org-timer-hms-to-secs "org-timer" (hms))
|
||||
(declare-function org-timer-item "org-timer" (&optional arg))
|
||||
(declare-function org-trim "org" (s &optional keep-lead))
|
||||
|
|
43
lisp/org.el
43
lisp/org.el
|
@ -17439,8 +17439,8 @@ both scheduled and deadline timestamps."
|
|||
'timestamp)
|
||||
(org-at-planning-p))
|
||||
(time-less-p
|
||||
(org-time-string-to-time match)
|
||||
(org-time-string-to-time d)))))))
|
||||
(org-time-string-to-time match t)
|
||||
(org-time-string-to-time d t)))))))
|
||||
(message "%d entries before %s"
|
||||
(org-occur regexp nil callback)
|
||||
d)))
|
||||
|
@ -17461,8 +17461,8 @@ both scheduled and deadline timestamps."
|
|||
'timestamp)
|
||||
(org-at-planning-p))
|
||||
(not (time-less-p
|
||||
(org-time-string-to-time match)
|
||||
(org-time-string-to-time d))))))))
|
||||
(org-time-string-to-time match t)
|
||||
(org-time-string-to-time d t))))))))
|
||||
(message "%d entries after %s"
|
||||
(org-occur regexp nil callback)
|
||||
d)))
|
||||
|
@ -17485,11 +17485,11 @@ both scheduled and deadline timestamps."
|
|||
'timestamp)
|
||||
(org-at-planning-p))
|
||||
(not (time-less-p
|
||||
(org-time-string-to-time match)
|
||||
(org-time-string-to-time start-date)))
|
||||
(org-time-string-to-time match t)
|
||||
(org-time-string-to-time start-date t)))
|
||||
(time-less-p
|
||||
(org-time-string-to-time match)
|
||||
(org-time-string-to-time end-date))))))))
|
||||
(org-time-string-to-time match t)
|
||||
(org-time-string-to-time end-date t))))))))
|
||||
(message "%d entries between %s and %s"
|
||||
(org-occur regexp nil callback) start-date end-date)))
|
||||
|
||||
|
@ -17574,19 +17574,19 @@ days in order to avoid rounding problems."
|
|||
(push m l))
|
||||
(apply 'format fmt (nreverse l))))
|
||||
|
||||
(defun org-time-string-to-time (s &optional buffer pos)
|
||||
"Convert a timestamp string into internal time."
|
||||
(condition-case errdata
|
||||
(apply 'encode-time (org-parse-time-string s))
|
||||
(error (error "Bad timestamp `%s'%s\nError was: %s"
|
||||
s (if (not (and buffer pos))
|
||||
""
|
||||
(format-message " at %d in buffer `%s'" pos buffer))
|
||||
(cdr errdata)))))
|
||||
(defun org-time-string-to-time (s &optional zone)
|
||||
"Convert timestamp string S into internal time.
|
||||
The optional ZONE is omitted or nil for Emacs local time, t for
|
||||
Universal Time, ‘wall’ for system wall clock time, or a string as
|
||||
in the TZ environment variable."
|
||||
(apply #'encode-time (org-parse-time-string s nil zone)))
|
||||
|
||||
(defun org-time-string-to-seconds (s)
|
||||
"Convert a timestamp string to a number of seconds."
|
||||
(float-time (org-time-string-to-time s)))
|
||||
(defun org-time-string-to-seconds (s &optional zone)
|
||||
"Convert a timestamp string S into a number of seconds.
|
||||
The optional ZONE is omitted or nil for Emacs local time, t for
|
||||
Universal Time, ‘wall’ for system wall clock time, or a string as
|
||||
in the TZ environment variable."
|
||||
(float-time (org-time-string-to-time s zone)))
|
||||
|
||||
(org-define-error 'org-diary-sexp-no-match "Unable to match diary sexp")
|
||||
|
||||
|
@ -18159,8 +18159,7 @@ A prefix ARG can be used to force the current date."
|
|||
(when (or (org-at-timestamp-p 'lax)
|
||||
(org-match-line (concat ".*" org-ts-regexp)))
|
||||
(let ((d1 (time-to-days (current-time)))
|
||||
(d2 (time-to-days
|
||||
(org-time-string-to-time (match-string 1)))))
|
||||
(d2 (time-to-days (org-time-string-to-time (match-string 1)))))
|
||||
(setq diff (- d2 d1))))
|
||||
(calendar)
|
||||
(calendar-goto-today)
|
||||
|
|
|
@ -48,8 +48,9 @@ range. INPUT2 can be omitted if clock hasn't finished yet.
|
|||
Return the clock line as a string."
|
||||
(let* ((beg (org-test-clock-create-timestamp input1 t t))
|
||||
(end (and input2 (org-test-clock-create-timestamp input2 t t)))
|
||||
(sec-diff (and input2 (floor (- (org-time-string-to-seconds end)
|
||||
(org-time-string-to-seconds beg))))))
|
||||
(sec-diff (and input2
|
||||
(floor (- (org-time-string-to-seconds end t)
|
||||
(org-time-string-to-seconds beg t))))))
|
||||
(concat org-clock-string " " beg
|
||||
(when end
|
||||
(concat "--" end " => "
|
||||
|
|
Loading…
Reference in New Issue