Rename `org-timestamp--to-internal-time' into `org-timestamp-to-time'

* lisp/org.el (org-timestamp-to-time): New function.
(org-timestamp--to-internal-time): Remove function.
(org-timestamp-format): Use new function.

* testing/lisp/test-org.el (test-org/timestamp-to-time): New test.
This commit is contained in:
Nicolas Goaziou 2018-01-10 14:39:09 +01:00
parent ee27fb010e
commit 728920a8ed
3 changed files with 61 additions and 6 deletions

View File

@ -196,6 +196,7 @@ a #+BEGIN_FOO/#+END_FOO block. Bound to C-c C-x w by default.
See docstring for details.
*** ~org-timestamp-to-time~
*** ~org-timestamp-from-string~
*** ~org-timestamp-from-time~
*** ~org-attach-dired-to-subtree~

View File

@ -22546,8 +22546,8 @@ return an active timestamp."
:hour-start (and with-time hour)
:minute-start (and with-time minute)))))
(defun org-timestamp--to-internal-time (timestamp &optional end)
"Encode TIMESTAMP object into Emacs internal time.
(defun org-timestamp-to-time (timestamp &optional end)
"Convert TIMESTAMP object into an Emacs internal time value.
Use end of date range or time range when END is non-nil.
Otherwise, use its start."
(apply #'encode-time
@ -22571,11 +22571,10 @@ FORMAT is a format specifier to be passed to
When optional argument END is non-nil, use end of date-range or
time-range, if possible.
When optional argument UTC is non-nil, time will be expressed as
When optional argument UTC is non-nil, time is be expressed as
Universal Time."
(format-time-string
format (org-timestamp--to-internal-time timestamp end)
(and utc t)))
(format-time-string format (org-timestamp-to-time timestamp end)
(and utc t)))
(defun org-timestamp-split-range (timestamp &optional end)
"Extract a TIMESTAMP object from a date or time range.

View File

@ -6510,6 +6510,61 @@ CLOCK: [2012-03-29 Thu 10:00]--[2012-03-29 Thu 16:40] => 6:40"
(org-element-interpret-data
(org-timestamp-from-time '(20339 35296) nil t))))))
(ert-deftest test-org/timestamp-to-time ()
"Test `org-timestamp-to-time' specifications."
(should
(equal "2014-03-04"
(format-time-string
"%Y-%m-%d"
(org-timestamp-to-time
(org-timestamp-from-string "<2014-03-04 Tue>")))))
(should
(equal "2014-03-04"
(format-time-string
"%Y-%m-%d"
(org-timestamp-to-time
(org-timestamp-from-string "[2014-03-04 Tue]")))))
(should
(equal "2012-03-29 08:30"
(format-time-string
"%Y-%m-%d %H:%M"
(org-timestamp-to-time
(org-timestamp-from-string "<2012-03-29 Thu 08:30-16:40>")))))
(should
(equal "2012-03-29"
(format-time-string
"%Y-%m-%d"
(org-timestamp-to-time
(org-timestamp-from-string "<2012-03-29 Thu>--<2014-03-04 Tue>")))))
(should
(equal "2012-03-29"
(format-time-string
"%Y-%m-%d"
(org-timestamp-to-time
(org-timestamp-from-string "[2012-03-29 Thu]--[2014-03-04 Tue]")))))
;; When optional argument END is non-nil, use end of date range or
;; time range.
(should
(equal "2012-03-29 16:40"
(format-time-string
"%Y-%m-%d %H:%M"
(org-timestamp-to-time
(org-timestamp-from-string "<2012-03-29 Thu 08:30-16:40>")
t))))
(should
(equal "2014-03-04"
(format-time-string
"%Y-%m-%d"
(org-timestamp-to-time
(org-timestamp-from-string "<2012-03-29 Thu>--<2014-03-04 Tue>")
t))))
(should
(equal "2014-03-04"
(format-time-string
"%Y-%m-%d"
(org-timestamp-to-time
(org-timestamp-from-string "[2012-03-29 Thu]--[2014-03-04 Tue]")
t)))))
;;; Visibility