Operating System - HP-UX
1833813 Members
3162 Online
110063 Solutions
New Discussion

Getting the proper TZ/DST information on a certain date

 
SOLVED
Go to solution
Michele (Mike) Alberton
Regular Advisor

Getting the proper TZ/DST information on a certain date

Hi Folks,

I need to find an easy way to know in advance if a certain date will be a DST or not using shell scrips.

I know I could analyze tztab to get to it, but I was wondering if there's something faster to know for instance if 08/10/05 will be a METDST or a MET (if I'm in Europe) or whatever is my local TZ.

Thanks in advance !

Mike
4 REPLIES 4
Robert-Jan Goossens
Honored Contributor

Re: Getting the proper TZ/DST information on a certain date

Mike,

something like,

# echo $TZ

Robert-Jan
Michele (Mike) Alberton
Regular Advisor

Re: Getting the proper TZ/DST information on a certain date

Nice try Robert-Jan :-)

Actually I would like to get information on a future date.
Let's say I want to know if 11/24/2038 will be a METDST or a MET.

$TZ wouldn't help being current TZ, which could be a different one by that time (I'm just talking DST).

Thanks,

Mike
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Getting the proper TZ/DST information on a certain date

Here is a Perl script that is very close and will even work in a Windows environment (if you have installed Perl) as well as UNIX.

For example:
dst.pl -y 2005 will display the time transitions for whatever value TZ is set to. It can also display the time left until the next transition.


Invoke as dst.pl -u for full usage.
If it ain't broke, I can fix that.
Michele (Mike) Alberton
Regular Advisor

Re: Getting the proper TZ/DST information on a certain date

Hi A. Clay !

That's pretty useful stuff. I could extract the target year and compare epoch timestamps to verify if I'm already on a different TZ.

Good shot, thanks !

Mike