Subject: Re: time-stamp & time-zone

From: Charles Curley <[email-masked]>
Date: Sat, 17 May 1997 08:25:57 -0600

At 01:23 17/5/97 -0400, Chris Weikart wrote:
>I've enabled time-stamping with the following:
>
>      (setq time-stamp-format "%3a %3b %2d %02H:%02M:%02S %Z %y by %u")
>      (setq time-stamp-start "Last modified on[ ]+\\\\?[.]*")
>      (setq time-stamp-end "\\\\?[.]*$")
>      (setq time-stamp-line-limit 999999) ;; big!
>      (if (not (memq 'time-stamp write-file-hooks))
>	  (setq write-file-hooks
>		(cons 'time-stamp write-file-hooks)))
>
>This works fine, except: the time-zone name ("EDT", for instance) is not
>where %Z should've put it. For example, I get:
>
>	;; Last modified on Sat May 17 01:13:31  1997 by weikart
>
>I found that this is because (by default) the "TZ" environment variable
>isn't set under Win95/NT. If I set it explicitly, like this:
>
>      (if (not (getenv "TZ")) (setenv "TZ" "EDT"))
>
>then things work:
>
>	;; Last modified on Sat May 17 01:13:31 EDT 1997 by weikart
>
>But I don't want to hardwire the name, I want to determine it. I can call
>(current-time-zone), which for EDT returns:
>
>	(-14400 "")
>
>And I can use a hack like this to return either "EDT" or "EST":
>
>      (defun current-time-zone-name ()
>	"Return the current east coast time-zone name [weikart]."
>	(let* ((z (current-time-zone))
>	       (name (car (cdr z))))
>	  (if (and name (not (equal name ""))) name
>	    (if (= (car z) -14400) "EDT" "EST"))))
>
>The function works in isolation, but if I use it to set "TZ":
>
>      (if (not (getenv "TZ")) (setenv "TZ" (current-time-zone-name)))
>
>then the time-zone name is once again missing from the time stamp. In fact,
>I find that subsequent calls to (current-time-zone) return:
>
>	(0 "EDT")
>
>And at this point I realize that (current-time-zone) depends on the "TZ"
>environment variable in ways that I'm too tired to go and puzzle out.
>
>So: how do I get the time-zone name into the time-stamp format?
>
>-Chris

The time stamp format should probably be the same as that used by Unix and
by PGP and other programs on Mess-DOS: set "TZ=stdhdlt", where std is the
standard time time zone desigantion, h is the hour delta from gmt, and dlt
is the daylight time zone designation. For example, in Wyoming, I use

SET TZ=MST7MDT

for Mountain Standard Time, 7 hours, and Mountain Daylight Time.

Try setting it in your autoexec.bat.

I have not worked with the time stamp stuff in Emacs, but I suspect that it
respects the format I have described here, and you can probably take out
the code you added.

Hope this helps.

		-- C^2

Looking for fine software and/or web pages?
http://web.idirect.com/~ccurley

---

From: Chris Weikart <[email-masked]>
Date: Sat, 17 May 1997 01:23:29 -0400

then things work:

	(-14400 "")

	(0 "EDT")

-Chris

_______________________________________________________________________
Chris Weikart <[email-masked]>     Digital Equipment Corporation
Speech Interaction Group (Web Apps)     Cambridge Research Laboratory
tel: (617) 692-7649, (DTN) 259-7649     One Kendall Square Bldg. 700
fax: (617) 692-7650, (DTN) 259-7650     Cambridge MA 02139-1562 USA

http://www.research.digital.com/CRL/personal/weikart/

---

From: Jason Rumney <[email-masked]>
Date: 19 May 1997 08:25:25 +1300

> SET TZ=MST7MDT

The format should support the *FULL* POSIX timezone standard.  Far too
many DOS/Windows implementations support only the subset mentioned
above - which is fine if daylight savings starts and ends at the same
time in your area as it does in Redmond, Washington.  It falls over
severely when you move into the Southern Hemisphere.

AFAIK Emacs supports whatever the compiler it was compiled on has
support for.  Prior to MSVC++ 4.2, timezones only worked properly in
countries with the same daylight savings rules as the US.  Now they
work properly if the TZ environment variable is NOT set (consulting
the registry for settings), but as soon as you set a TZ variable you
are stuck with the lame subset of POSIX sepecified above.