Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Mar 1999 07:00:35 +1000
From:      Greg Black <gjb@comkey.com.au>
To:        Kelly Yancey <kbyanc@alcnet.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: proper way to set TZ? 
Message-ID:  <19990318210036.15257.qmail@alpha.comkey.com.au>
In-Reply-To: <Pine.BSF.4.05.9903181050330.53892-100000@kronos.alcnet.com>  of Thu, 18 Mar 1999 10:57:48 EST
References:  <Pine.BSF.4.05.9903181050330.53892-100000@kronos.alcnet.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
> > >   I have a couple of scripts which rely on TZ being set to the server's
> > > time zone. What is the proper was to do this so I don't have to put a
> > > TZ=EST; export TZ before invoking any of the scripts.

The real puzzle is: why do you want to do this?  Are you dealing
with multiple machines running in different timezones?

>   Hmm. The problem is that the scripts are currently written in perl
> (which doesn't actually have a built-in interface to ctime, although I
> suppose if I get desparate I could make a ph file from the c header). I
> have already written some code which splits all the information out of
> gmtime or localtime in perl but it can't get the timezone.

I refuse to use Perl, but this does seem unlikely.

> It would seem
> that my solutions are limited to:
> 
>   Just invoking the date command and stripping the trailing newline
>   (downside: fork overhead just to get the time)

Bear in mind that the date command can output any details you
want, so all your other perl code to manipulate it can be tossed
away.  How much of a burden is the fork?

>   Living without the timezone
>   (downside: I really need the timezone recorded in logs)

Then, this is not an alternative for you.

>   Where exactly does the ctime() get it's timezone information? Where is
> it recorded...I can set it with tzset but I can't get the information back
> out. I really appreciate the help!

The broken down fields live in the `struct tm' defined in
/usr/include/time.h (which, incidentally, spells UTC wrong).
That struct also provides the much more useful time zone offset
value as well as the silly time zone name field.  If you can't
extract the data you want in Perl, it's an incredibly trivial
thing in C.

Somehow, I think that we could help you better if we just knew
a bit more about the problem ...

-- 
Greg Black <gjb@acm.org>



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990318210036.15257.qmail>