diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-12-19 12:57:25 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-12-19 13:01:42 -0800 |
commit | 5bd6074415e8d572931ee51112d9b70b70e2ba55 (patch) | |
tree | 197616a9cf72bd188a9201274f0840afac93fac2 /lisp/calc/calc-forms.el | |
parent | 3fa8bdca88153ff442ca22d8c298525c1b716e7e (diff) | |
download | emacs-5bd6074415e8d572931ee51112d9b70b70e2ba55.tar.gz |
Minor fixes/simplifications to time functions
* doc/lispintro/emacs-lisp-intro.texi (Files List): Simplify.
* doc/lispref/os.texi (Time of Day): Mention format-time-string
as an alternative to current-time-string.
* lisp/arc-mode.el (archive-unixdate, archive-unixtime):
Port better to future versions of Emacs where (COUNT . HZ)
will take precedence to (HI . LO).
* lisp/arc-mode.el (archive-unixtime):
* lisp/calendar/todo-mode.el (todo-insert-item--basic)
(todo-item-done, todo-read-time):
Prefer format-time-string to substringing current-time-string.
* lisp/calc/calc-forms.el (calc-time, calcFunc-now):
Prefer decode-time to parsing the output of current-time-string.
* lisp/emacs-lisp/cl-extra.el (cl--random-time):
Prefer encode-time to hashing the output of current-time-string.
* lisp/gnus/gnus-score.el (gnus-score-headers)
(gnus-score-adaptive):
Avoid stringifying and then reparsing timestamp.
* src/timefns.c (Fencode_time): Omit redundant assignment.
Diffstat (limited to 'lisp/calc/calc-forms.el')
-rw-r--r-- | lisp/calc/calc-forms.el | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el index f7586288ca2..ccd52d370d1 100644 --- a/lisp/calc/calc-forms.el +++ b/lisp/calc/calc-forms.el @@ -37,13 +37,11 @@ (defun calc-time () (interactive) (calc-wrapper - (let ((time (current-time-string))) + (let ((time (decode-time))) (calc-enter-result 0 "time" (list 'mod (list 'hms - (string-to-number (substring time 11 13)) - (string-to-number (substring time 14 16)) - (string-to-number (substring time 17 19))) + (nth 2 time) (nth 1 time) (nth 0 time)) (list 'hms 24 0 0)))))) (defun calc-to-hms (arg) @@ -1341,16 +1339,15 @@ as measured in the integer number of days before December 31, 1 BC (Gregorian)." (math-parse-iso-date-validate isoyear isoweek isoweekday hour minute second))))) (defun calcFunc-now (&optional zone) - (let ((date (let ((calc-date-format nil)) - (math-parse-date (current-time-string))))) - (if (consp date) - (if zone - (math-add date (math-div (math-sub (calcFunc-tzone nil date) - (calcFunc-tzone zone date)) - '(float 864 2))) - date) - (calc-record-why "*Unable to interpret current date from system") - (append (list 'calcFunc-now) (and zone (list zone)))))) + (let ((date (let ((now (decode-time))) + (list 'date (math-dt-to-date + (list (nth 5 now) (nth 4 now) (nth 3 now) + (nth 2 now) (nth 1 now) (nth 0 now))))))) + (if zone + (math-add date (math-div (math-sub (calcFunc-tzone nil date) + (calcFunc-tzone zone date)) + '(float 864 2))) + date))) (defun calcFunc-year (date) (car (math-date-to-dt date))) |