Local Vs GMT date and times

Q&A's, tips, howto's
Locked
CaveGuy
Posts: 112
Joined: Sun Oct 13, 2002 3:00 pm
Location: Columbus Ohio
Contact:

Local Vs GMT date and times

Post 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)))
Bob the Caveguy aka Lord High Fixer.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

CaveGuy
Posts: 112
Joined: Sun Oct 13, 2002 3:00 pm
Location: Columbus Ohio
Contact:

Post 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.
Bob the Caveguy aka Lord High Fixer.

Locked