summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-01-10 14:39:09 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-01-10 15:05:11 +0100
commit728920a8edf7e24ae1656b2a6bfaeb7c58b15012 (patch)
treee992bee82735f29445ff45c59ae74581f9e9ddee
parentee27fb010ed0d1adbb8670c21241c69ebfb757a3 (diff)
downloadorg-mode-728920a8edf7e24ae1656b2a6bfaeb7c58b15012.tar.gz
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.
-rw-r--r--etc/ORG-NEWS1
-rw-r--r--lisp/org.el11
-rw-r--r--testing/lisp/test-org.el55
3 files changed, 61 insertions, 6 deletions
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 3495e6e..67f5140 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -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~
diff --git a/lisp/org.el b/lisp/org.el
index 2de3714..00a127e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -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.
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index ab618f0..2e1d189 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -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