Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TZ to calculate date not working

Status
Not open for further replies.

pjb

Programmer
May 1, 2001
148
US
I have a script used for adding and subtracting days from current that uses TZ. It multiplys the days by 24 to get hours, adjusts for the time zone and the combines TZ with the date command. to add a day it does TZ=EDT-20 date. To subtract, TZ=EDT+28 date. A two day intercal would use 44 or 52 hours and so on. This works on all my boxes except the new one. On that machine, I can only add or subtract 1 day. If the command uses more than 24 hours going forward, it returns the current date. Ging backwads, it returns current date regardless of the number of hours. I have searched and tried all the various examples, variations and FAQ's on this site, and the results on the new box are always the same. It is if the parameters are ignored
 
I read somewhere (on this site I believe) that some unixes do not allow offsetting TZ further than + or - 24 hrs...


HTH,

p5wizard
 
What is the new box"

Good question. What is the best way to tell?
 
Err... you could look at it and see what it says on the front of it. :)

Or, the output of uname -a might help.

Annihilannic.
 
Ah, It's HP-UX. Everything else I use are SunOs. Darn, that could be the problem.
 
man tzset on HPUX ;)

perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'
 
There is a FAQ on this forum with an alternative method."

Like I said in my original post, I tried all of those. The simple methods using the TZ will not work, and I was trying to stay away from a long sub-routine or seperate shell. I do have a C program I can use, though I was looking for the simple TZ method

 
What are you environment variables, they're different on HPUX (if that's what you're using) Settings are usually /usr/lib/tztab instead of /usr/lib/locale/TZ or ANYTHING/TZ

perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'
 
Sorry, didn't re-read your original post. However, did you try the one that doesn't use TZ? How/why did that not work on HP-UX?

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top