- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Possible time discrepancy?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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
тАО04-08-2009 10:01 AM
тАО04-08-2009 10:01 AM
Here's a sample program to show what I mean:
#include
#include
#include
#include
#include
#include
#define TICKS_PER_SEC 10000000LL
static $DESCRIPTOR(dt, "1-JAN-1970 00:00:00.0");
int main()
{
__int64 epoch, tm, t;
struct timespec clk;
/*
* The epoch should be last 45 days of 1858 (from Nov 17)
* plus 365 days/year for 111 years (1859 through 1969)
* plus 27 days for leap years = 40587 days
* or 3506716800 seconds
* or a system time of 35067168000000000
*/
lib$convert_date_string(&dt, &epoch);
printf("lib$convert_date_string gives %lld as the epoch...", epoch);
if (epoch == 35067168000000000LL)
printf("correct\n\n");
else {
printf("wrong\n\n");
return EXIT_FAILURE;
}
/*
* The epoch should be the difference between these times.
*/
clock_gettime(CLOCK_REALTIME, &clk);
sys$gettim(&tm);
t = ((__int64) clk.tv_sec) * TICKS_PER_SEC
+ ((__int64) clk.tv_nsec) / 100;
printf("system time : %lld\n", tm);
printf("- clock_gettime : %lld\n", t);
printf("= difference : %lld\n", tm - t);
printf("- epoch : %lld\n", epoch);
printf("= off by : %lld\n", tm - t - epoch);
return EXIT_SUCCESS;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2009 10:54 AM
тАО04-08-2009 10:54 AM
Re: Possible time discrepancy?
I suspect the difference here is due to the use of 17-NOV-1858 in localtime, and the use of 1-Jan-1970 in UTC, and the timezone settings.
I'm disinclined to debug this C code to prove this theory, given the use of E8.2 here, and given that tested and working and portable OpenVMS epoch time conversion code is available here:
http://labs.hoffmanlabs.com/node/735
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2009 02:01 PM
тАО04-08-2009 02:01 PM
Re: Possible time discrepancy?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2009 03:09 PM
тАО04-08-2009 03:09 PM
SolutionOpenVMS uses its own 17-Nov-1858 epoch; the saved time is the number of centiseconds since that time, local. Local. Not GMT. Usually stored in a quadword.
Classic OpenVMS system services do not know about timezones and such. It's all local time, as far as the classic services are concerned.
OpenVMS uses local time as the time base. Not GMT/UTC. No DST.
Newer services can deal with TZs, but the older ones don't.
Unix and C uses its own 1-Jan-1970 epoch, and uses GMT/UTC as its base time.
Unix calls return either the epoch GMT/UTC or returns localtime, depending on the call.
The Unix C calls do the time-math to get from the OpenVMS native base time maintained by and within OpenVMS to GMT/UTC and then (if needed) along to localtime as required. (BTW: when this particular stuff isn't fully and correctly configured and current on its rules around daylight saving time (DST), you'll end up with the time off by an hour; time values reported by OpenVMS and Unix will be reported differently.)
Follow the timekeeping link around on the site I referenced. I've posted a whole lot on this topic over there.
http://labs.hoffmanlabs.com/taxonomy/term/57
pedant note 1: Yes, I'm aware that GMT and UTC are not the same.
pedant note 2: Yes, I'm aware that there can be optimizations made in the C time calculations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2009 07:18 AM
тАО04-09-2009 07:18 AM