summaryrefslogtreecommitdiff
path: root/lisp/calendar/time-date.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2020-08-05 10:07:13 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2020-08-05 10:07:13 +0200
commit1f3e2ac4b62e38af2d9424f2a4fcc1515a4c0b30 (patch)
tree96a4cb668edba38f83ffefe6b88d050b4486d979 /lisp/calendar/time-date.el
parent398242bb3f08db3be4d8f1a7a95ba44f7aea995c (diff)
downloademacs-1f3e2ac4b62e38af2d9424f2a4fcc1515a4c0b30.tar.gz
Add new function decoded-time-period
* lisp/calendar/time-date.el (decoded-time-period): New function.
Diffstat (limited to 'lisp/calendar/time-date.el')
-rw-r--r--lisp/calendar/time-date.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el
index eeb09926a6e..125f9acc705 100644
--- a/lisp/calendar/time-date.el
+++ b/lisp/calendar/time-date.el
@@ -527,6 +527,21 @@ TIME is modified and returned."
time)
+(defun decoded-time-period (time)
+ "Interpret DECODED as a period and return its length in seconds.
+For computational purposes, years are 365 days long and months
+are 30 days long."
+ (+ (if (consp (decoded-time-second time))
+ ;; Fractional second.
+ (/ (float (car (decoded-time-second time)))
+ (cdr (decoded-time-second time)))
+ (or (decoded-time-second time) 0))
+ (* (or (decoded-time-minute time) 0) 60)
+ (* (or (decoded-time-hour time) 0) 60 60)
+ (* (or (decoded-time-day time) 0) 60 60 24)
+ (* (or (decoded-time-month time) 0) 60 60 24 30)
+ (* (or (decoded-time-year time) 0) 60 60 24 365)))
+
(provide 'time-date)
;;; time-date.el ends here