source: trunk/src/kernel32/time.cpp@ 8765

Last change on this file since 8765 was 8765, checked in by sandervl, 23 years ago

fix

File size: 7.8 KB
Line 
1/* $Id: time.cpp,v 1.20 2002-06-25 18:01:53 sandervl Exp $ */
2
3/*
4 * Win32 time/date API functions
5 *
6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
7 * Copyright 1999 Christoph Bratschi (cbratschi@datacomm.ch)
8 *
9 * Copyright 1996 Alexandre Julliard
10 * Copyright 1995 Martin von Loewis
11 * Copyright 1998 David Lee Lambert
12
13 *
14 * Project Odin Software License can be found in LICENSE.TXT
15 */
16
17
18/*****************************************************************************
19 * Includes *
20 *****************************************************************************/
21
22#include <odin.h>
23#include <odinwrap.h>
24#include <os2sel.h>
25
26#include <os2win.h>
27
28#include <winnls.h>
29#include "winuser.h"
30#include <stdlib.h>
31#include <string.h>
32#include <stdio.h>
33#include <time.h>
34#include "unicode.h"
35
36#define DBG_LOCALLOG DBG_time
37#include "dbglocal.h"
38
39/*****************************************************************************
40 * Defines *
41 *****************************************************************************/
42
43ODINDEBUGCHANNEL(KERNEL32-TIME)
44
45
46
47#define lstrcpynAtoW(unicode,ascii,asciilen) AsciiToUnicodeN(ascii,unicode,asciilen);
48
49#define WPRINTF_LEFTALIGN 0x0001 /* Align output on the left ('-' prefix) */
50#define WPRINTF_PREFIX_HEX 0x0002 /* Prefix hex with 0x ('#' prefix) */
51#define WPRINTF_ZEROPAD 0x0004 /* Pad with zeros ('0' prefix) */
52#define WPRINTF_LONG 0x0008 /* Long arg ('l' prefix) */
53#define WPRINTF_SHORT 0x0010 /* Short arg ('h' prefix) */
54#define WPRINTF_UPPER_HEX 0x0020 /* Upper-case hex ('X' specifier) */
55#define WPRINTF_WIDE 0x0040 /* Wide arg ('w' prefix) */
56
57typedef enum
58{
59 WPR_UNKNOWN,
60 WPR_CHAR,
61 WPR_WCHAR,
62 WPR_STRING,
63 WPR_WSTRING,
64 WPR_SIGNED,
65 WPR_UNSIGNED,
66 WPR_HEXA
67} WPRINTF_TYPE;
68
69typedef struct
70{
71 UINT flags;
72 UINT width;
73 UINT precision;
74 WPRINTF_TYPE type;
75} WPRINTF_FORMAT;
76
77typedef union {
78 WCHAR wchar_view;
79 CHAR char_view;
80 LPCSTR lpcstr_view;
81 LPCWSTR lpcwstr_view;
82 INT int_view;
83} WPRINTF_DATA;
84
85static const CHAR null_stringA[] = "(null)";
86static const WCHAR null_stringW[] = { '(', 'n', 'u', 'l', 'l', ')', 0 };
87
88//******************************************************************************
89//******************************************************************************
90void WIN32API GetLocalTime(LPSYSTEMTIME arg1)
91{
92 O32_GetLocalTime(arg1);
93}
94//******************************************************************************
95//******************************************************************************
96BOOL WIN32API SetLocalTime(const SYSTEMTIME * arg1)
97{
98 return O32_SetLocalTime(arg1);
99}
100//******************************************************************************
101//******************************************************************************
102BOOL WIN32API FileTimeToDosDateTime(const FILETIME * arg1, LPWORD arg2,
103 LPWORD arg3)
104{
105 return O32_FileTimeToDosDateTime(arg1, arg2, arg3);
106}
107
108//******************************************************************************
109//******************************************************************************
110BOOL WIN32API FileTimeToLocalFileTime(const FILETIME * utcft, LPFILETIME localft)
111{
112 return O32_FileTimeToLocalFileTime(utcft,localft);
113}
114//******************************************************************************
115//******************************************************************************
116BOOL WIN32API LocalFileTimeToFileTime(const FILETIME * arg1, LPFILETIME arg2)
117{
118 dprintf(("KERNEL32: LocalFileTimeToFileTime\n"));
119 return O32_LocalFileTimeToFileTime(arg1, arg2);
120}
121//******************************************************************************
122//******************************************************************************
123BOOL WIN32API FileTimeToSystemTime(const FILETIME * arg1, LPSYSTEMTIME arg2)
124{
125 return O32_FileTimeToSystemTime(arg1, arg2);
126}
127//******************************************************************************
128//******************************************************************************
129BOOL WIN32API DosDateTimeToFileTime(WORD arg1, WORD arg2, LPFILETIME arg3)
130{
131 BOOL rc;
132 rc = O32_DosDateTimeToFileTime(arg1, arg2, arg3);
133 /* Bug in WGSS after that we must have UCT file time on return,
134 instead we have local! */
135 if (rc)
136 {
137 FILETIME dummy;
138 /* Convert it to UCT */
139 rc = LocalFileTimeToFileTime(arg3,&dummy);
140 memcpy(arg3,&dummy,sizeof(FILETIME));
141 }
142 return rc;
143}
144//******************************************************************************
145//******************************************************************************
146DWORD WIN32API GetTimeZoneInformation(LPTIME_ZONE_INFORMATION arg1)
147{
148 return O32_GetTimeZoneInformation(arg1);
149}
150//******************************************************************************
151//******************************************************************************
152DWORD WIN32API GetTickCount(void)
153{
154//// dprintf(("KERNEL32: GetTickCount\n"));
155 return O32_GetTickCount();
156}
157//******************************************************************************
158//******************************************************************************
159void WIN32API GetSystemTime(LPSYSTEMTIME arg1)
160{
161 O32_GetSystemTime(arg1);
162}
163//******************************************************************************
164//******************************************************************************
165BOOL WIN32API SystemTimeToFileTime(const SYSTEMTIME * arg1,
166 LPFILETIME arg2)
167{
168 BOOL rc;
169 rc = O32_SystemTimeToFileTime(arg1, arg2);
170 /* Bug in WGSS after that we must have UCT file time on return,
171 instead we have local! */
172 if (rc)
173 {
174 FILETIME dummy;
175 /* Convert it to local */
176 rc = LocalFileTimeToFileTime(arg2,&dummy);
177 memcpy(arg2,&dummy,sizeof(FILETIME));
178 }
179 return rc;
180}
181//******************************************************************************
182//******************************************************************************
183BOOL WIN32API SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION arg1,
184 LPSYSTEMTIME arg2,
185 LPSYSTEMTIME arg3)
186{
187 return O32_SystemTimeToTzSpecificLocalTime(arg1, arg2, arg3);
188}
189//******************************************************************************
190//******************************************************************************
191BOOL WIN32API SetTimeZoneInformation(const LPTIME_ZONE_INFORMATION arg1)
192{
193 return O32_SetTimeZoneInformation(arg1);
194}
195//******************************************************************************
196//******************************************************************************
197BOOL WIN32API SetSystemTime(const SYSTEMTIME * arg1)
198{
199 return O32_SetSystemTime(arg1);
200}
201/*****************************************************************************
202 * Name : DWORD GetSystemTimeAsFileTime
203 * Purpose : The GetSystemTimeAsFileTime function obtains the current system
204 * date and time. The information is in Coordinated Universal Time (UTC) format.
205 * Parameters: LLPFILETIME lLPSYSTEMTIMEAsFileTime
206 * Variables :
207 * Result :
208 * Remark :
209 * Status : UNTESTED
210 *
211 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
212 *****************************************************************************/
213
214VOID WIN32API GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime)
215{
216 FILETIME ft; /* code sequence from WIN32.HLP */
217 SYSTEMTIME st;
218
219 dprintf(("KERNEL32: GetSystemTimeAsFileTime(%08xh)\n", lpSystemTimeAsFileTime));
220
221 GetSystemTime(&st);
222 SystemTimeToFileTime(&st, &ft);
223}
Note: See TracBrowser for help on using the repository browser.