Re: Testing for daylight savings on a GMT server
snoopy__at_excite.com
Date: 11/03/05
- Next message: Logan Shaw: "Re: When was the SPARC 20 introduced and discontinued?"
- Previous message: Logan Shaw: "Re: MEDIA: Sun's 128-bit ZFS file system to ship this month"
- Maybe in reply to: Mothra: "Re: Testing for daylight savings on a GMT server"
- Next in thread: Gordon Burditt: "Re: Testing for daylight savings on a GMT server"
- Reply: Gordon Burditt: "Re: Testing for daylight savings on a GMT server"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 3 Nov 2005 14:09:11 -0800
paul,
You're exactly right. Other scripts I set the TZ specifically, but
in this one it was missing which caused the problem. I use the TZ in
other scripts to catch specific information during certain hours in
logs, but in this script I assumed that perl would be able to tell if
DST was in effect or not, but while in GMT I guess it can't deliver
that information because it's senseless. However, taking your advice
it runs perfectly. Thank you very much.
Paul Lalli wrote:
> snoopy_@excite.com wrote:
> > I have a server that is set to GMT and it needs to interact with
> > other servers that are not and the other servers also observe daylight
> > savings time adjustments. I am trying to re-write some scripts that do
> > not require any changes due to the timechange, I thought I found the
> > cure via perl's localtime function, but this last weekend showed me
> > that since my box is set to GMT it doesn't care about DST and perl
> > won't pick up the change.
> >
> > Here's what I was using (our code standard is ksh):
> >
> > chk_dst()
> > {
> > DST=`/usr/bin/perl -e '($isdst) = (localtime)[8]; print
> > "$isdst\n";'`
> > if [ $DST == 0 ]; then
> > TIME1=14
> > TIME2=19
> > elif [ $DST == 1 ]; then
> > TIME1=15
> > TIME2=20
> > elif [ $DST -ge -1 ]; then
> > echo "Cannot determine system time" >> /tmp/dstTime.out
> > fi
> > }
> >
> > I was hopping to see a "0" when we are out of DST, and a "1" when we
> > were in DST. Neither seems to be the case. I also tried setting my
> > TZ variable to a local time, but I haven't seen any changes. It
> > appears the issue is that since my box is set to GMT, I won't be able
> > to use perl to get the DST info. Any suggestions?
> >
>
> Are you sure $TZ didn't affect anything? It seems to for me...
> $ echo $TZ
> US/Eastern
> $ perl -le'print ((localtime(time))[8])'
> 0
> $ perl -le'print ((localtime(time - 60*60*24*3))[8])'
> 1
> $ export TZ=GMT
> $ perl -le'print ((localtime(time))[8])'
> 0
> $ perl -le'print ((localtime(time - 60*60*24*3))[8])'
> 0
>
> I'm first checking the isDST value of the current day/time (2005-10-31
> 11:48:00), then of 3 days previous. Then I change timezones to GMT,
> and check the two dates again. When in Eastern time, isDST is false
> for right now, but true for three days ago, while it's always false
> when in GMT.
>
> Paul Lalli
- Next message: Logan Shaw: "Re: When was the SPARC 20 introduced and discontinued?"
- Previous message: Logan Shaw: "Re: MEDIA: Sun's 128-bit ZFS file system to ship this month"
- Maybe in reply to: Mothra: "Re: Testing for daylight savings on a GMT server"
- Next in thread: Gordon Burditt: "Re: Testing for daylight savings on a GMT server"
- Reply: Gordon Burditt: "Re: Testing for daylight savings on a GMT server"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|