diff options
Diffstat (limited to 'lisp/calc/calc-forms.el')
-rw-r--r-- | lisp/calc/calc-forms.el | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el index e521eaeaff2..bdfc0e44ddd 100644 --- a/lisp/calc/calc-forms.el +++ b/lisp/calc/calc-forms.el @@ -37,13 +37,13 @@ (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))) + (decoded-time-hour time) + (decoded-time-minute time) + (decoded-time-second time)) (list 'hms 24 0 0)))))) (defun calc-to-hms (arg) @@ -62,7 +62,7 @@ (defun calc-hms-notation (fmt) - (interactive "sHours-minutes-seconds format (hms, @ \\=' \", etc.): ") + (interactive "sHours-minutes-seconds format (hms, @ ' \", etc.): ") (calc-wrapper (if (string-match "\\`\\([^,; ]+\\)\\([,; ]*\\)\\([^,; ]\\)\\([,; ]*\\)\\([^,; ]\\)\\'" fmt) (progn @@ -525,7 +525,7 @@ in the Gregorian calendar and the remaining part determines the time." (defun math-this-year () - (nth 5 (decode-time))) + (decoded-time-year (decode-time))) (defun math-leap-year-p (year &optional julian) "Non-nil if YEAR is a leap year. @@ -1341,16 +1341,19 @@ 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 (decoded-time-year now) + (decoded-time-month now) + (decoded-time-day now) + (decoded-time-hour now) + (decoded-time-minute now) + (decoded-time-second 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))) @@ -1475,9 +1478,6 @@ as measured in the integer number of days before December 31, 1 BC (Gregorian)." (defvar var-TimeZone nil) -;; From cal-dst -(defvar calendar-current-time-zone-cache) - (defvar math-calendar-tzinfo nil "Information about the timezone, retrieved from the calendar.") @@ -1490,11 +1490,9 @@ second, the number of seconds offset for daylight savings." (if math-calendar-tzinfo math-calendar-tzinfo (require 'cal-dst) - (let ((tzinfo (progn - (calendar-current-time-zone) - calendar-current-time-zone-cache))) + (let ((tzinfo (calendar-current-time-zone))) (setq math-calendar-tzinfo - (list (* 60 (abs (nth 0 tzinfo))) + (list (* 60 (- (nth 0 tzinfo))) (* 60 (nth 1 tzinfo))))))) (defun calcFunc-tzone (&optional zone date) |