Define time constants and refactor time routines to use them
This commit is contained in:
@@ -53,6 +53,13 @@
|
|||||||
#define SHA1_BLOCK_SIZE 64
|
#define SHA1_BLOCK_SIZE 64
|
||||||
#define SHA1_DIGEST_SIZE 20
|
#define SHA1_DIGEST_SIZE 20
|
||||||
|
|
||||||
|
/* Time related definitions */
|
||||||
|
#define TIME_SECONDS_PER_MINUTE 60ULL
|
||||||
|
#define TIME_SECONDS_PER_HOUR 3600ULL
|
||||||
|
#define TIME_SECONDS_PER_DAY 86400ULL
|
||||||
|
#define TIME_TICKS_PER_SECOND 10000000ULL
|
||||||
|
#define TIME_TICKS_PER_MILLISECOND 10000ULL
|
||||||
|
|
||||||
|
|
||||||
/* C/C++ specific code */
|
/* C/C++ specific code */
|
||||||
#ifndef __XTOS_ASSEMBLER__
|
#ifndef __XTOS_ASSEMBLER__
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ RTL::Time::TimeFieldsToUnixEpoch(IN PTIME_FIELDS TimeFields,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert 100-nanosecond intervals (TICKS) to whole seconds */
|
/* Convert 100-nanosecond intervals (TICKS) to whole seconds */
|
||||||
TotalSeconds = XtTime.QuadPart / TICKS_PER_SECOND;
|
TotalSeconds = XtTime.QuadPart / TIME_TICKS_PER_SECOND;
|
||||||
|
|
||||||
/* Subtract the number of seconds between January 1, 1601 and January 1, 1970 */
|
/* Subtract the number of seconds between January 1, 1601 and January 1, 1970 */
|
||||||
*UnixTime = TotalSeconds - 11644473600LL;
|
*UnixTime = TotalSeconds - 11644473600LL;
|
||||||
@@ -116,13 +116,14 @@ RTL::Time::TimeFieldsToXtEpoch(IN PTIME_FIELDS TimeFields,
|
|||||||
ElapsedDays += (TimeFields->Day - 1);
|
ElapsedDays += (TimeFields->Day - 1);
|
||||||
|
|
||||||
/* Calculate a total number of seconds */
|
/* Calculate a total number of seconds */
|
||||||
TotalSeconds = ((ULONGLONG)ElapsedDays * SECONDS_PER_DAY) +
|
TotalSeconds = ((ULONGLONG)ElapsedDays * TIME_SECONDS_PER_DAY) +
|
||||||
((ULONGLONG)TimeFields->Hour * SECONDS_PER_HOUR) +
|
((ULONGLONG)TimeFields->Hour * TIME_SECONDS_PER_HOUR) +
|
||||||
((ULONGLONG)TimeFields->Minute * SECONDS_PER_MINUTE) +
|
((ULONGLONG)TimeFields->Minute * TIME_SECONDS_PER_MINUTE) +
|
||||||
(ULONGLONG)TimeFields->Second;
|
(ULONGLONG)TimeFields->Second;
|
||||||
|
|
||||||
/* Convert to 100-ns intervals and slap milliseconds on top */
|
/* Convert to 100-ns intervals and slap milliseconds on top */
|
||||||
Time->QuadPart = (TotalSeconds * TICKS_PER_SECOND) + ((ULONGLONG)TimeFields->Milliseconds * TICKS_PER_MILLISECOND);
|
XtTime->QuadPart = (TotalSeconds * TIME_TICKS_PER_SECOND) +
|
||||||
|
((ULONGLONG)TimeFields->Milliseconds * TIME_TICKS_PER_MILLISECOND);
|
||||||
|
|
||||||
/* Return success */
|
/* Return success */
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|||||||
Reference in New Issue
Block a user