Skip to content
Snippets Groups Projects
Commit d5b77fcf authored by ram's avatar ram
Browse files

/usr/mbb/x3j13-changes/current/time.lisp, 11-Jul-89 20:20:04, Edit by Mbb.

  Made a simple tweak to DECODE-UNIVERSAL-TIME that, in compliance with the
  new standard, ignores daylight-savings-time when the user supplies the
  :time-zone argument.
parent 4fe7d898
No related branches found
No related tags found
No related merge requests found
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
(+ (* (- weeks weeks-offset) seconds-in-week) (+ (* (- weeks weeks-offset) seconds-in-week)
(- (truncate msec 1000) seconds-offset))) (- (truncate msec 1000) seconds-offset)))
;;; Get-Universal-Time -- Public ;;; Get-Universal-Time -- Public
;;; ;;;
;;; ;;;
...@@ -106,25 +107,17 @@ ...@@ -106,25 +107,17 @@
(declare (ignore res)) (declare (ignore res))
(+ secs unix-to-universal-time))) (+ secs unix-to-universal-time)))
;;; Get-Decoded-Time -- Public
;;;
;;;
(defun get-decoded-time () (defun get-decoded-time ()
"Returns nine values specifying the current time as follows: "Returns nine values specifying the current time as follows:
second, minute, hour, date, month, year, day of week (0 = Monday), second, minute, hour, date, month, year, day of week (0 = Monday), T
T (daylight savings times) or NIL (standard time), and timezone." (daylight savings times) or NIL (standard time), and timezone."
(decode-universal-time (get-universal-time))) (decode-universal-time (get-universal-time)))
;;; Decode-Universal-Time -- Public
;;;
;;;
(defun decode-universal-time (universal-time &optional time-zone) (defun decode-universal-time (universal-time &optional time-zone)
"Converts a universal-time to decoded time format returning "Converts a universal-time to decoded time format returning the following
the following nine values: second, minute, hour, date, month, nine values: second, minute, hour, date, month, year, day of week (0 =
year, day of week (0 = Monday), T (daylight savings time) or Monday), T (daylight savings time) or NIL (standard time), and timezone.
NIL (standard time), and timezone." Completely ignores daylight-savings-time when time-zone is supplied."
(declare (type (or fixnum null) time-zone)) (declare (type (or fixnum null) time-zone))
(multiple-value-bind (weeks secs) (multiple-value-bind (weeks secs)
(truncate (+ universal-time seconds-offset) (truncate (+ universal-time seconds-offset)
...@@ -161,16 +154,17 @@ ...@@ -161,16 +154,17 @@
(let ((days-since-mar0 (1+ (truncate (mod t2 quarter-days-per-year) (let ((days-since-mar0 (1+ (truncate (mod t2 quarter-days-per-year)
4)))) 4))))
(setq day (mod (+ tday weekday-november-17-1858) 7)) (setq day (mod (+ tday weekday-november-17-1858) 7))
(if (setq daylight (dst-check days-since-mar0 hour day)) (unless time-zone
(cond ((eq hour 23) (if (setq daylight (dst-check days-since-mar0 hour day))
(setq hour 0) (cond ((eq hour 23)
(setq day (mod (1+ day) 7)) (setq hour 0)
(setq days-since-mar0 (1+ days-since-mar0)) (setq day (mod (1+ day) 7))
(if (>= days-since-mar0 366) (setq days-since-mar0 (1+ days-since-mar0))
(if (or (> days-since-mar0 366) (if (>= days-since-mar0 366)
(not-leap-year (1+ year))) (if (or (> days-since-mar0 366)
(setq days-since-mar0 368)))) (not-leap-year (1+ year)))
(T (setq hour (1+ hour))))) (setq days-since-mar0 368))))
(T (setq hour (1+ hour))))))
(let ((t3 (+ (* days-since-mar0 5) 456))) (let ((t3 (+ (* days-since-mar0 5) 456)))
(cond ((>= t3 1989) (cond ((>= t3 1989)
(setq t3 (- t3 1836)) (setq t3 (- t3 1836))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment