From owner-freebsd-questions Thu Mar 18 13:38:53 1999 Delivered-To: freebsd-questions@freebsd.org Received: from alpha.comkey.com.au (alpha.comkey.com.au [203.9.152.215]) by hub.freebsd.org (Postfix) with SMTP id A4E7214C81 for ; Thu, 18 Mar 1999 13:38:45 -0800 (PST) (envelope-from gjb@comkey.com.au) Received: (qmail 15258 invoked by uid 1001); 18 Mar 1999 21:00:36 -0000 Message-ID: <19990318210036.15257.qmail@alpha.comkey.com.au> X-Posted-By: GBA-Post 1.04 06-Feb-1999 X-PGP-Fingerprint: 5A91 6942 8CEA 9DAB B95B C249 1CE1 493B 2B5A CE30 Date: Fri, 19 Mar 1999 07:00:35 +1000 From: Greg Black To: Kelly Yancey Cc: freebsd-questions@FreeBSD.ORG Subject: Re: proper way to set TZ? References: In-reply-to: of Thu, 18 Mar 1999 10:57:48 EST Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > > 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message