Next time change? (10 Views)
Reply
Occasional Contributor
James Kirk_1
Posts: 7
Registered: ‎01-21-2004
Message 1 of 4 (10 Views)
Accepted Solution

Next time change?

Hi,

I would like to create some kind of automatic notification of the next daylight saving time change. Is there a command to display the number of days until the next time change or the date of the next time change?

Thanks in advance for any and all help,
Jim
Please use plain text.
Acclaimed Contributor
A. Clay Stephenson
Posts: 17,825
Registered: ‎07-16-1998
Message 2 of 4 (10 Views)

Re: Next time change?

First of all, you should know that there is no need to do anything on a UNIX box. All UNIX boxes in the known universe simply count seconds since 00:00:00 01/01/1970 UTC. TZ (Timezone) only affects how the time is DISPLAYED and moreover, there is no one TZ; each user on the box could have his own custom TZ. You could parse /usr/lib/tztab on HP-UX boxes and try to figure this out but the good news is that I have a Perl script that will do this (and it even works on Windows if one of the freely available Perl's is installed).

Use it like this:
DAYS=$(dst.pl -d -e)
echo "${DAYS} until time change"

(drop the -e and floating-point days will be returned; with -e integer days will be returned; invoke as dst.pl -u for full usage)

If it ain't broke, I can fix that.
Please use plain text.
Acclaimed Contributor
A. Clay Stephenson
Posts: 17,825
Registered: ‎07-16-1998
Message 3 of 4 (10 Views)

Re: Next time change?

I should add that this is only as good as the current setting of TZ. Different TZ's will get different values. If you cron this, make sure that your set and export TZ to the desired value and set PATH as well.
If it ain't broke, I can fix that.
Please use plain text.
Occasional Contributor
James Kirk_1
Posts: 7
Registered: ‎01-21-2004
Message 4 of 4 (10 Views)

Re: Next time change?

Thank you Clay. This morning I received a mail message saying that there were 46 days until the next time change. Your script worked perfectly.

Thanks,
Jim
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation