1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/*++
Copyright (c) 1989 Microsoft Corporation
Module Name:
datetime.c
Abstract:
This module contains the function to retrive time and date information.
Author:
Michael Jarus (mjarus) 04-Jan-1993
Revision History:
--*/
#define INCL_OS2V20_ERRORS
#include "os2ssrtl.h"
#if DBG
extern ULONG Os2Debug;
#endif
APIRET
Or2GetDateTimeInfo(
PLARGE_INTEGER pSystemTime,
PLARGE_INTEGER pLocalTime,
PTIME_FIELDS pNtDateTime,
PVOID pSystemInformation,
PSHORT pTimeZone
)
{
NTSTATUS Status;
ULONG Remainder;
BOOLEAN Sign;
LARGE_INTEGER ZoneTime;
PSYSTEM_TIMEOFDAY_INFORMATION pLocalSystemInformation =
(PSYSTEM_TIMEOFDAY_INFORMATION)pSystemInformation;
Status = NtQuerySystemTime(
pSystemTime
);
if (!NT_SUCCESS( Status ))
{
#if DBG
IF_OS2_DEBUG ( TIMERS )
{
KdPrint(("Or2GetDateTimeInfo: NtQuerySystemTime rc %lx\n",
Status));
}
#endif
return (Or2MapNtStatusToOs2Error(Status, ERROR_INVALID_PARAMETER ));
}
//
// Convert UTC to Local time
//
Status = RtlSystemTimeToLocalTime (
pSystemTime,
pLocalTime
);
if (!NT_SUCCESS( Status ))
{
#if DBG
IF_OS2_DEBUG ( TIMERS )
{
KdPrint(("Or2GetDateTimeInfo: RtlSystemTimeToLocalTime rc %lx\n",
Status));
}
#endif
return (Or2MapNtStatusToOs2Error(Status, ERROR_INVALID_PARAMETER ));
}
RtlTimeToTimeFields( pLocalTime, pNtDateTime );
Status = NtQuerySystemInformation (
SystemTimeOfDayInformation,
pSystemInformation,
sizeof(SYSTEM_TIMEOFDAY_INFORMATION),
NULL
);
if (!NT_SUCCESS(Status))
{
#if DBG
IF_OS2_DEBUG ( TIMERS )
{
KdPrint(("Or2sGetDateTimInfoe: NtQuerySystemInformation rc %lx\n",
Status));
}
#endif
return (Or2MapNtStatusToOs2Error(Status, ERROR_INVALID_PARAMETER ));
}
if (pLocalSystemInformation->TimeZoneBias.HighPart < 0)
{
Sign = TRUE;
pLocalSystemInformation->TimeZoneBias = RtlLargeIntegerNegate(
pLocalSystemInformation->TimeZoneBias
);
} else
{
Sign = FALSE;
}
ZoneTime = RtlExtendedLargeIntegerDivide (
pLocalSystemInformation->TimeZoneBias,
60*1000*10000, /* converts 100nSec to Min */
&Remainder
);
if (Sign)
{
*pTimeZone = -(SHORT)ZoneTime.LowPart;
} else
{
*pTimeZone = (SHORT)ZoneTime.LowPart;
}
return(0);
}
|