HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Timezone info in C++ on HP-UX...
Operating System - HP-UX
1827293
Members
2695
Online
109717
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2002 02:41 PM
02-06-2002 02:41 PM
Timezone info in C++ on HP-UX...
Hi,
Much of our code depeneds on current time AND timezone/daylight information. We use the ftime() routine to tell us what timezone we're in (as an offset from GMT) as well as whether daylight savings time is currently in effect.
The problem is that our code doesn't work as expected on HP-UX 11i, compiled with aCC 03.30. We are in EST (5 hours behind GMT), yet the ftime() results on HP-UX show that we are 7 hours behind GMT, AND that daylight savings time is in effect NOW.
I've created a small test app which works correctly on Win32 and Linux, but gives the wrong time from ftime() on HP-UX (though the global timezone variable appears to have the right value, strangely enough).
Any thoughts? Anything I have to pre-initialize before calling ftime()? Anything in the OS that needs setting before these will work (the TZ environment variable is set to EST5EDT, and the global "timezone" variable works right...)? Thanks in advance for any insight or tips you can pass along.
Allan Stirrett.
Much of our code depeneds on current time AND timezone/daylight information. We use the ftime() routine to tell us what timezone we're in (as an offset from GMT) as well as whether daylight savings time is currently in effect.
The problem is that our code doesn't work as expected on HP-UX 11i, compiled with aCC 03.30. We are in EST (5 hours behind GMT), yet the ftime() results on HP-UX show that we are 7 hours behind GMT, AND that daylight savings time is in effect NOW.
I've created a small test app which works correctly on Win32 and Linux, but gives the wrong time from ftime() on HP-UX (though the global timezone variable appears to have the right value, strangely enough).
Any thoughts? Anything I have to pre-initialize before calling ftime()? Anything in the OS that needs setting before these will work (the TZ environment variable is set to EST5EDT, and the global "timezone" variable works right...)? Thanks in advance for any insight or tips you can pass along.
Allan Stirrett.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2002 03:16 PM
02-06-2002 03:16 PM
Re: Timezone info in C++ on HP-UX...
Hi Allan:
Instead of using 'ftime()' use 'ctime{}'. 'ftime()' leverages the deprecated kernel parameter 'timezone' (and 'dst') instead of the TZ environmental variable.
Regards!
...JRF...
Instead of using 'ftime()' use 'ctime{}'. 'ftime()' leverages the deprecated kernel parameter 'timezone' (and 'dst') instead of the TZ environmental variable.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2002 03:29 PM
02-06-2002 03:29 PM
Re: Timezone info in C++ on HP-UX...
Hi Allan:
ftime() is one of those archaic functions which should never be used in a modern program.
The function you should be using is ctime() and it is available in Linux and Microsoft C++.
If you also need the high resolution that ftime provides you can use gettimeofday() or use ftime() only for the millitm values and time values. You can then send the time value into ctime() to get the time properly decoded.
ftime() is one of those archaic functions which should never be used in a modern program.
The function you should be using is ctime() and it is available in Linux and Microsoft C++.
If you also need the high resolution that ftime provides you can use gettimeofday() or use ftime() only for the millitm values and time values. You can then send the time value into ctime() to get the time properly decoded.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2002 08:21 PM
02-06-2002 08:21 PM
Re: Timezone info in C++ on HP-UX...
Hi,
Thanks for the replies. I think I found the answer in a man page that pointed in a different direction.
It looks like what I really want to use on ALL platforms is localtime(). It sets the global "timezone" value correctly on all 4 of our platforms, and the "struct tm" that it returns contains a tm_isdst flag which CONSISTENTLY tells us whether we're CURRENTLY in daylight savings time (the dstflag from ftime() was interpretted differently in different OS's).
This gives us the info we need to convert time_t's to/from a foreign date/time format. Thanks again for the suggestions.
Allan Stirrett.
Thanks for the replies. I think I found the answer in a man page that pointed in a different direction.
It looks like what I really want to use on ALL platforms is localtime(). It sets the global "timezone" value correctly on all 4 of our platforms, and the "struct tm" that it returns contains a tm_isdst flag which CONSISTENTLY tells us whether we're CURRENTLY in daylight savings time (the dstflag from ftime() was interpretted differently in different OS's).
This gives us the info we need to convert time_t's to/from a foreign date/time format. Thanks again for the suggestions.
Allan Stirrett.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP