Operating System - HP-UX
1833772 Members
2181 Online
110063 Solutions
New Discussion

How to know if time change will work this weekend?

 
SOLVED
Go to solution
John Chaff
Advisor

How to know if time change will work this weekend?

Hi experts:

I have looked at the tztab file on my system and it looks ok. Without changing the system date is there a way to know if the time change will work this weekend?

TIA,
John
8 REPLIES 8
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: How to know if time change will work this weekend?

HP's Official response: Trust me.

Actually the time doesn't change just the way the time is displayed changes. If you want to test it, run the attached Perl script, dst.pl.

Run it like this: dst.pl -n or as dst.pl -u for full usage.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: How to know if time change will work this weekend?

I should also add that you might have TZ's in play by users all over the woorld so you can test those by setting TZ before running the command:

TZ=EST5EDT dst.pl -n
TZ=CST6CDT dst.pl -n

The good news is that this routine uses the same libc functions that the date command uses so that if the Perl script displays the correct transition, the date command and programs which use localtime(), strftime(), et al will work as well -- Trust me. It doesn't directly look at the tztab file ; it uses the functions that look at this file.

If you have one of the freely available Perl's for Windows boxes, it will even test them.
If it ain't broke, I can fix that.
John Chaff
Advisor

Re: How to know if time change will work this weekend?

Thanks Clay. Your script doesn't acctually change the system date and then reset it does it? We have some databases and I don't want to mess them up datewise.

TIA,
John
A. Clay Stephenson
Acclaimed Contributor

Re: How to know if time change will work this weekend?

No, it's safe. Trust me. It essentially does a binary diminishing search changing the epoch seconds fed to localtime() until the $isdst (Is Daylight Saving Time) value changes. It hunts until it finds the exact second before and after that $isdst flips and stops. It doesn't do anything with the system time itself. Of course, to be safe try it on a Windows box first. Who cares if one of those things explodes? Certainly not me.
If it ain't broke, I can fix that.
John Chaff
Advisor

Re: How to know if time change will work this weekend?

Thanks Clay.

Your script worked great and I did try it on a Windows server first!

Thanks again,
John
John Chaff
Advisor

Re: How to know if time change will work this weekend?

Hi (again) Clay:

What happens if the timezone variable is set to
something like GMT? Does your search still work
or does it hang? Just curious.

TIA,
John
A. Clay Stephenson
Acclaimed Contributor

Re: How to know if time change will work this weekend?

Well John, if you were really curious instead of chicken you would do something like this:

TZ=GMT0 dst.pl -n
echo ${?}

OR

you could simply display the usage via dst.pl -u and if you look, you might just find your answer.

I prefer Plan A myself because you never know, I might be lying to you in them there usage messages.

If it ain't broke, I can fix that.
John Chaff
Advisor

Re: How to know if time change will work this weekend?

Hi Clay:

Duh! I feel really stupid. I had already output the usage and the answer was right there!

Stupidly yours truly,
John