Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a function for parsing ISO-8601 date time strings #15

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/test.el
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@
(ts-unix)
(equal 1443070800.0)))))))

(ert-deftest ts-parse-iso8601 ()
(let* ((iso8601-string "2015-09-24T00:00:00+00:00"))
(should (equal 1443070800.0 (ts-unix (ts-parse-iso8601 iso8601-string))))))

;;;;; Other

(ert-deftest ts-apply ()
Expand Down
4 changes: 4 additions & 0 deletions ts.el
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ not support timestamps that contain seconds."
(_ (error "FILL must be `begin' or `end'")))
(make-ts :second second :minute minute :hour hour :day day :month month :year year)))

(defsubst ts-parse-iso8601 (iso-8601)
"Return timestamp object for an ISO-8601 date string."
(make-ts :unix (float-time (parse-iso8601-time-string iso-8601))))

;;;; Functions

(cl-defun ts-apply (&rest args)
Expand Down