SUMMARY Re: a timezone question ...

From: Lucio Chiappetti <lucio_at_ifctr.mi.cnr.it>
Date: Fri, 31 Mar 2000 18:16:34 +0200 (MET DST)

On Fri, 31 Mar 2000, Lucio Chiappetti wrote:

> I thought that an easy way to obtain the "official" time in another timezone
> (inclusive of DST setting) i.e. "what time is now in XXXX if here it is
> hh:mm" was the following :
>
> (setenv TZ timezone ; date)

The prize goes to Oisin McGuinness which has sent the working solution, deeply
buried in the man pages !

First the (correct but) unsatisfactory replies :

--------------------
From: Dave Simmonds

I think you want: TZ=AAAN date Where AAA is the 3 long alpha code and N is the
number of hours away from

--------------------
From: Joerg Bruehe

Obviously 'date' needs the TZ value to include the offset - did you really use
'GMT+0' or 'PST+8' whatever you need ? For me, it worked (only) with the
numeric offset.

--------------------
From: Paul A Sand

( setenv TZ GMT0 ; date )

I'm not sure what the `legal' values are for TZ in order to make this work,
though. TZ=GMT-8 seems to work, but TZ=Hongkong doesn't.


The problems with all the above is that you need to tell the offset from GMT
(so what's the sense if one wants to know what the time at place xyz without
reading the /etc/zoneinfo/ to know in which zone it is ? And in particular if
you want to profit of the content of the compiled files to know automatically
whether the particular place has daylight saving time on or not !)

But here is the right answer :

------------------------
From: Oisin McGuinness

try ( setenv TZ ":EDT" ; date) That is, use a : in front of the timezone name.
This is appropriate for BSD and Posix environments. man 3 timezone gives more
details.


Of all the man pages it was the one I did not look. I tried it as follows :

cd /etc/zoneinfo
foreach i (*)
 echo $i
 date --> local time in local timezone
 (setenv TZ ":$i" ; date) --> remote date
 echo $<
end

This works and gives meaningful results for all true zones. Not in all cases
the acronym is in the form MET DST, but I assume when it is xST like BST means
saving time is in effect, otherwise not (e.g. EET). Details should be in the
sources.

Caveat is that for Australia, Brazil, Chile (my first try) , Canada, Mexico
and US, they are directories, so one should use the appropriate path instead.

----------------------------------------------------------------------------
Lucio Chiappetti - IFCTR/CNR - via Bassini 15 - I-20133 Milano (Italy)
----------------------------------------------------------------------------
"This land .. is my land .. e no xe una portaerei"
[English in the original] [and is not an aircraft carrier]
                             M.Paolini - I cani del gas - Bestiario italiano
----------------------------------------------------------------------------
For more info : http://www.ifctr.mi.cnr.it/~lucio/personal.html
----------------------------------------------------------------------------
Received on Fri Mar 31 2000 - 16:18:51 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:40 NZDT