Line 528... |
Line 528... |
/* Compared to usual UNIX time_t, VMS time has less limits:
|
/* Compared to usual UNIX time_t, VMS time has less limits:
|
- 64 bit (63 bits in fact as the MSB must be 0)
|
- 64 bit (63 bits in fact as the MSB must be 0)
|
- 100ns granularity
|
- 100ns granularity
|
- epoch is Nov 17, 1858.
|
- epoch is Nov 17, 1858.
|
Here has the constants and the routines used to convert VMS from/to UNIX time.
|
Here has the constants and the routines used to convert VMS from/to UNIX time.
|
The conversion routines don't assume 64 bits arithmetic. */
|
The conversion routines don't assume 64 bits arithmetic.
|
|
|
|
Here we assume that the definition of time_t is the UNIX one, ie integer
|
|
type, expressing seconds since the epoch. */
|
|
|
/* UNIX time granularity for VMS, ie 1s / 100ns. */
|
/* UNIX time granularity for VMS, ie 1s / 100ns. */
|
#define VMS_TIME_FACTOR 10000000
|
#define VMS_TIME_FACTOR 10000000
|
|
|
/* Number of seconds since VMS epoch of the UNIX epoch. */
|
/* Number of seconds since VMS epoch of the UNIX epoch. */
|
Line 544... |
Line 547... |
vms_time_to_time_t (unsigned int hi, unsigned int lo)
|
vms_time_to_time_t (unsigned int hi, unsigned int lo)
|
{
|
{
|
unsigned int tmp;
|
unsigned int tmp;
|
unsigned int rlo;
|
unsigned int rlo;
|
int i;
|
int i;
|
|
time_t res;
|
|
|
/* First convert to seconds. */
|
/* First convert to seconds. */
|
tmp = hi % VMS_TIME_FACTOR;
|
tmp = hi % VMS_TIME_FACTOR;
|
hi = hi / VMS_TIME_FACTOR;
|
hi = hi / VMS_TIME_FACTOR;
|
rlo = 0;
|
rlo = 0;
|
Line 560... |
Line 564... |
tmp %= VMS_TIME_FACTOR;
|
tmp %= VMS_TIME_FACTOR;
|
}
|
}
|
lo = rlo;
|
lo = rlo;
|
|
|
/* Return 0 in case of overflow. */
|
/* Return 0 in case of overflow. */
|
if (lo > VMS_TIME_OFFSET && hi > 1)
|
if (hi > 1
|
|
|| (hi == 1 && lo >= VMS_TIME_OFFSET))
|
return 0;
|
return 0;
|
|
|
/* Return 0 in case of underflow. */
|
/* Return 0 in case of underflow. */
|
if (lo < VMS_TIME_OFFSET)
|
if (hi == 0 && lo < VMS_TIME_OFFSET)
|
return 0;
|
return 0;
|
|
|
return lo - VMS_TIME_OFFSET;
|
res = lo - VMS_TIME_OFFSET;
|
|
if (res <= 0)
|
|
return 0;
|
|
return res;
|
}
|
}
|
|
|
/* Convert a time_t to a VMS time. */
|
/* Convert a time_t to a VMS time. */
|
|
|
void
|
void
|