Sponsored Content
Top Forums Programming TZ, localtime and strftime problem on AIX and Solaris Post 302800647 by biju64 on Tuesday 30th of April 2013 08:45:06 AM
Old 04-30-2013
Quote:
Originally Posted by shamrock
Can you post the output of the following command...
Code:
ls -la /usr/share/lib/zoneinfo/Europe

Thanks for replying.
You may have found the problem (partially)...

On our AIX machine, the 'Europe' folder does not exist.
However we have a file called GB-Eire under the /usr/share/lib/zoneinfo directory.

When I set TZ to GB-Eire, I get the correct output (ie. same output as when I set TZ to Posix format GMT0BST,M3.5.0,M10.5.0)

I changed the strftime and the timeString variables as follows:
Code:
 char timeString[30];
strftime( timeString, sizeof( timeString), "%d-%b-%Y %H:%M:%S", &timeHolder);

<snip>
Secs: 3599 Time: 01-Jan-1970 00:59:59
Secs: 3600 Time: 01-Jan-1970 01:00:00
Secs: 3601 Time: 01-Jan-1970 01:00:01
<snip>

But on our Solaris machine, we have the 'Europe/London' folder and file, a GB file and a GB-Eire file. Setting TZ to any of these does not work. All give:

<snip>
Secs: 3599 Time: 01-Jan-1970 01:59:59
Secs: 3600 Time: 01-Jan-1970 02:00:00
Secs: 3601 Time: 01-Jan-1970 02:00:01
<snip>

Which is different from what I get when I set TZ to Posix format : GMT0BST,M3.5.0,M10.5.0

<snip>
Secs: 3599 Time: 01-Jan-1970 00:59:59
Secs: 3600 Time: 01-Jan-1970 01:00:00
Secs: 3601 Time: 01-Jan-1970 01:00:01
<snip>

Strange...so it looks like it might work correctly when I get the 'Europe/London' file under zoneinfo folder on AIX (will need to test this)...but not sure why it does not work on Solaris.

---------- Post updated at 01:45 PM ---------- Previous update was at 01:09 PM ----------

Quote:
Originally Posted by jim mcnamara
I ran your code. The reason is because in 1970 daylight savings did not work the way it does now. I edited you code and added a %c to the format string + more space in the output string:
This is what I get with Mountain/Denver TZ on Solaris:

Secs: 3599 Time: Wed Dec 31 17:59:59 1969 17:59:59
Secs: 3600 Time: Wed Dec 31 18:00:00 1969 18:00:00
Secs: 3601 Time: Wed Dec 31 18:00:01 1969 18:00:01

FYI: DST does not work in winter in London, and most countries including North America had odd ball timezone settings way back then, if they even had it. I could go on. Your long variables "secs" should also be a time_t. Try starting with:

Code:
secs=1367265312

and count forward from there.
Thanks for replying.
I agree that the DST does not apply in winter in London. But I would expect that if I set TZ in Posix (GMT0BST,M3.5.0,M10.5.0) or Olson (Europe/London) formats, I should get the same output (this is on Solaris where I have the '/usr/share/lib/zoneinfo/Europe/London' file).

When I try starting at 1367275312 onwards it does match. But then these are when DST is ON and it always works correctly (as in both posix/olson outputs match) when DST is ON. Same when I set to 8598706 (when DST is ON and in the 1970s):

Secs: 8598706 Time: 10-Apr-1970 13:31:46

On both formats, I get the same answer.

So the problem exists only when DST is off and looking at my reply to 'Shamrock' above, maybe only on Solaris (as AIX seems to work for GB, EB-Eire and if I have 'Europe/London' may work too).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl + localtime()

ok here is a perl date question not asked befor. i know i am feeling small for not knowing. BUT!!!! $ENV{TZ}="US/Central"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(); how can i do the addition to year so i can get the current year w/o going $ntime=$year+1900;... (3 Replies)
Discussion started by: Optimus_P
3 Replies

2. UNIX for Advanced & Expert Users

converting localtime to unixtime

hi, how to convert the localtime to unixtime? i have date from the date command in unix i want to convert it into unixtime thnx (2 Replies)
Discussion started by: AshishK
2 Replies

3. Solaris

AIX & Solaris 10 problem

I have this command in my script and it's working fine with AIX: ls init?*.ora 2>/dev/null | egrep -i -e "" the same command is failing in Solaris 10. does anyone have better idea how to make it work for both ? Thanks (1 Reply)
Discussion started by: talashil
1 Replies

4. Shell Programming and Scripting

gawk and strftime()

Strange behaviour of the strftime() function from gawk (3.1.5): $ awk 'BEGIN{print strftime("%T", 3600)}' > 02:00:00 $ awk 'BEGIN{print strftime("%T", 0)}' > 01:00:00 Obviously something with DST but I can not figure out why? To me 3600 epoch seconds remains 01:00, DST or not. From... (2 Replies)
Discussion started by: ripat
2 Replies

5. Shell Programming and Scripting

PERL localtime Warning

Hello All, I am facing a warning "Argument "" isn't numeric in localtime at" what i m using is below my $timestamp = Timestamp(time); go_log("###############$timestamp###############"); can some one please suggest the way to avoid this message :confused: (6 Replies)
Discussion started by: NIMISH AGARWAL
6 Replies

6. Shell Programming and Scripting

date with perl localtime

Hi Experts, I know how to handle normal date changes in perl. Most of my requirement are full filled with following: $date1 = strftime "%Y%m%d",localtime; $date2 = strftime "%Y%m%d",localtime(time -24 * 60 * 60); $date3 = strftime "%Y%m%d",localtime(time +24 * 60 * 60); $date4 = strftime... (4 Replies)
Discussion started by: mtomar
4 Replies

7. Programming

strftime equivalent in c++

HI, i wish to convert a millsec value to a readable string format. the one option is to use strftime. However this is a bit costly (1-5 micros). is there a a faster way to do so with just string manipulation (Note i have the date object which has the time details but wish o avoid strftime) (2 Replies)
Discussion started by: wojtyla
2 Replies

8. Shell Programming and Scripting

Perl help LocalTime in New Format

Hi, I'm new to perl scripting and am trying it out. I have a file written in the following format: myfile-MMDDYY where MM is the number of the Month; DD the Day and YY the last two of the year... (Apologies for dumbing this down; I'm trying to be clear). There is a new file put onto my... (2 Replies)
Discussion started by: Astrocloud
2 Replies

9. Shell Programming and Scripting

How to use a variable in perl localtime()?

Hi all, a=$1 ## b=`echo "86400 * $a"|bc` `perl -e 'use POSIX qw(strftime);$now_string = strftime "%d/%m/%Y", localtime(time-$b); print $now_string,"\n";' > date_file` but im always getting current date; can any one suggest me any the improvement the above works fine if i use some thing... (2 Replies)
Discussion started by: zozoo
2 Replies

10. Shell Programming and Scripting

Help on awk strftime

cat file 41285.000034722223 41285.000567129631 41285.000069444446 41285.001122685186 41285.000092592592 41285.001620370371 41285.000138888892 41285.00340277778 41285.000185185185 41285.000405092593 41285.000196759262 41285.000856481478 41285.000208333331 41285.000717592593... (5 Replies)
Discussion started by: phpshell
5 Replies
All times are GMT -4. The time now is 06:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy