1752421 Members
6079 Online
108788 Solutions
New Discussion юеВ

Re: Next time change?

 
SOLVED
Go to solution
James Kirk_1
Occasional Contributor

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
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

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.
A. Clay Stephenson
Acclaimed Contributor

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.
James Kirk_1
Occasional Contributor

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