Operating System - Linux
1753675 Members
5314 Online
108799 Solutions
New Discussion юеВ

Time make_time(const char* str) setting the wrong timezone for Australia-Eastern

 
SOLVED
Go to solution
Peyhwa Yuen
New Member

Time make_time(const char* str) setting the wrong timezone for Australia-Eastern

The server is running HPUX 11.11 with DST patch PHCO_36097.

Timezone on the server is EST-10EDT i.e. Australia-Eastern.

I wrote a simple program as below to
- get current time using time
- convert current time to Time object
- print Time object
- get a datetime string from screen
- convert to Time object
- print Time object

This program runs perfectly in US EST/EDT timezone, but timezone was completedly wrong under EST-10EDT timezone, see output below:


pumbaa:date
Wed Apr 25 07:19:39 EST 2007
pumbaa:/tmp/DST
current time is Wed Apr 25 07:19:45 2007

year:2007
month:04
day:25
hour:07
minute:19
second:45
timezone:EDT
Enter date string as mm/dd/yyyy?12/10/2007
Enter time string as hh:mm?8:8:8
String: 12/10/2007 8:8:8become:
year:2007
month:12
day:10
hour:08
minute:08
second:08
timezone:EST
Converting this time to time_t=1197238088
convert to string is Mon Dec 10 09:08:08 2007

What did I missed?

3 REPLIES 3
Dennis Handly
Acclaimed Contributor
Solution

Re: Time make_time(const char* str) setting the wrong timezone for Australia-Eastern

(I'm having this moved to Languages, since it is unlikely anybody would know what you are asking.)

You are using the obsolete USL Standard Components. This was only made available for users porting from cfront and they were told to immediately port to the C++ Standard Lib instead. In the case of Time, you should be using the Standard C ctime(3).

You should NOT be using the Time component since it ONLY supports US timezones DST transitions. See Place(3). Note RWZone has similar issues.

Since you in the southern hemisphere, this will not work for you at all.

Some of this info is documented on:
http://h21007.www2.hp.com/dspp/files/unprotected/DST2.pdf
Peyhwa Yuen
New Member

Re: Time make_time(const char* str) setting the wrong timezone for Australia-Eastern

Dennis,

This is the first time I heard about the limitation of Time.

I guess I will have to change to use ctime related function instead.

Thanks.

-Peyhwa
Dennis Handly
Acclaimed Contributor

Re: Time make_time(const char* str) setting the wrong timezone for Australia-Eastern

>This is the first time I heard about the limitation of Time.

Well, it has always been there under Place(3). And if you ever tried it, it should be off by 1 hour, nearly all of the year.

Also, lib++.a is not available on Integrity.