timedate()




On Fri, 16 Apr 2010, Edwin Woollett wrote:

< Is there any way to set GMT hours diff
< to get timedate() to produce the pacific
< standard time?
< 
< At about 4:40 pm in California, I get:
< 
<  timedate();  --->  "2010-04-17 00:39:50+01:00"
< 
< Thanks in advance,
< Ted Woollett
< 
 
Ted, timedate can be patched to give you the functionality
you want. The patched code replicates timedate() while
timedate(+8) will give you the offset time.


Leo

(defmvar $time_zone_offset nil
  "The offset of the local time zone from GMT. This offset does
not account for daylight savings.")

(defun $timedate (&optional (tz-offset $time_zone_offset))
  (multiple-value-bind
    (second minute hour date month year day-of-week dst-p tz)
    (decode-universal-time (get-universal-time) tz-offset)
    (declare (ignore day-of-week))
    (let
      ((tz-offset (if dst-p (- 1 tz) (- tz))))
      (multiple-value-bind
        (tz-hours tz-hour-fraction)
        (floor tz-offset)
        (let
          ((tz-sign (if (< 0 tz-hours) #\+ #\-)))
          (format nil "~4,'0d-~2,'0d-~2,'0d
~2,'0d:~2,'0d:~2,'0d~a~2,'0d:~2,'0d"
              year month date hour minute second tz-sign (abs tz-hours)
(floor (* 60 tz-hour-fraction))))))))


-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.