Page 1 of 1

Local Vs GMT date and times

PostPosted: Wed Feb 26, 2003 6:06 pm
by CaveGuy
currentily:
(now) => (2003 2 26 21 49 19 875000 57 4) in GMT!
and
(date (apply date-value (now))) =>
"Wed Feb 26 19:12:04 2003" corrected to Local Time

Goal goal was/is to generate a log file name XX20030326.log
that changes to XX20030327.log midnight local time.

(define make-log-file-name ( log-path , month day datestamp)
(setq rightnow (now)
datestamp (parse (date (apply date-value IT:rightnow)))
month (find (nth 1 datestamp)
'("" "bob" "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul"
"Aug" "Sep" "Oct" "Nov" "Dec"))
month (if (< month 10) (append "0" (string month)) (string month))
day (nth 2 datestamp)
day (if (< (length day) 2) (append "0" day) day))
(append log-path "XX" (string (nth 6 datestamp)) month day ".log"))

Returns <log-path>XXyyyymmdd.log

Wish List item:
(now) with an offest or time-zone or a local-flag,
That returned (2003 2 26 21 49 19 875000 57 4)
(now local-flag) format corrected for local time or any
specified timezone would be great!

Here is a snipit that will return the current local time in HH:MM:SS format:

(setq datestamp (parse (date (apply date-value (now))))
timestamp (append (string (nth 3 datestamp))
(string (nth 4 datestamp)) ":"
(string (nth 5 datestamp)))

PostPosted: Thu Feb 27, 2003 5:48 pm
by Lutz
An adjustment for local time in the 'now' function sounds like a good Idea, perhaps one could enter an offset parameter in hours like: (now -3)

That would also cover situations where you do software on a remote computer but you want localtime in your posts, logfiles etc.

Note, that the 'date function converts to ascii as of the localtime. Perhaps an additional hour-offset-parameter on that function would also be a good idea, then one would have optimal flexibility.

Lutz

PostPosted: Thu Feb 27, 2003 10:00 pm
by CaveGuy
(now -3) would work out very nicely !!

I like that idea. It would be nice to normalize to local time log format from multiple timezones. IE. east and west coast servers writing to the same log file in chicago or denver.

Note, that the 'date function converts to ascii as of the localtime. Perhaps an additional hour-offset-parameter on that function would also be a good idea, then one would have optimal flexibility.

Lutz


That would be great it would allow for normalization between multiple time-zones for reporting or display purposes.