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

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

minor updates

File size: 8.4 KB
Line 
1/* $Id: time.cpp,v 1.22 2002-06-26 10:18:27 sandervl Exp $ */
2
3/*
4 * Win32 time/date API functions
5 *
6 * Copyright 1998-2002 Sander van Leeuwen (sandervl@xs4all.nl)
7 * Copyright 1999 Christoph Bratschi (cbratschi@datacomm.ch)
8 *
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 */
12
13
14/*****************************************************************************
15 * Includes *
16 *****************************************************************************/
17
18#include <odin.h>
19#include <odinwrap.h>
20#include <os2sel.h>
21
22#include <os2win.h>
23
24#include <winnls.h>
25#include "winuser.h"
26#include <stdlib.h>
27#include <string.h>
28#include <stdio.h>
29#include <time.h>
30#include "unicode.h"
31#include "oslibtime.h"
32
33#define DBG_LOCALLOG DBG_time
34#include "dbglocal.h"
35
36
37//******************************************************************************
38//File time (UTC) to MS-DOS date & time values (also UTC)
39//******************************************************************************
40BOOL WIN32API FileTimeToDosDateTime(const FILETIME *lpFileTime, LPWORD lpDosDate,
41 LPWORD lpDosTime)
42{
43 if(lpFileTime == NULL || lpDosDate == NULL || lpDosTime == NULL )
44 {
45 SetLastError(ERROR_INVALID_PARAMETER);
46 return FALSE;
47 }
48 return O32_FileTimeToDosDateTime(lpFileTime, lpDosDate, lpDosTime);
49}
50//******************************************************************************
51//File time (UTC) to local time
52//******************************************************************************
53BOOL WIN32API FileTimeToLocalFileTime(const FILETIME *lpFileTime, LPFILETIME lpLocalTime)
54{
55 if(lpFileTime == NULL || lpLocalTime == NULL || lpFileTime == lpLocalTime)
56 {
57 SetLastError(ERROR_INVALID_PARAMETER);
58 return FALSE;
59 }
60 return O32_FileTimeToLocalFileTime(lpFileTime, lpLocalTime);
61}
62//******************************************************************************
63//Local time to File time (UTC)
64//******************************************************************************
65BOOL WIN32API LocalFileTimeToFileTime(const FILETIME *lpLocalFileTime,
66 LPFILETIME lpFileTime)
67{
68 BOOL ret;
69
70 if(!lpLocalFileTime || !lpFileTime || lpLocalFileTime == lpFileTime) {
71 dprintf(("!WARNING!: invalid parameter"));
72 SetLastError(ERROR_INVALID_PARAMETER);
73 return FALSE;
74 }
75 dprintf(("KERNEL32: LocalFileTimeToFileTime %x%x", lpLocalFileTime->dwHighDateTime, lpLocalFileTime->dwLowDateTime));
76 ret = O32_LocalFileTimeToFileTime(lpLocalFileTime, lpFileTime);
77 dprintf(("KERNEL32: LocalFileTimeToFileTime %x%x -> %d", lpFileTime->dwHighDateTime, lpFileTime->dwLowDateTime, ret));
78 return ret;
79}
80//******************************************************************************
81//File time (UTC) to System time (UTC)
82//******************************************************************************
83BOOL WIN32API FileTimeToSystemTime(const FILETIME *lpFileTime, LPSYSTEMTIME lpSystemTime)
84{
85 BOOL ret;
86
87 if(lpFileTime == NULL || lpSystemTime == NULL)
88 {
89 SetLastError(ERROR_INVALID_PARAMETER);
90 return FALSE;
91 }
92
93 ret = O32_FileTimeToSystemTime(lpFileTime, lpSystemTime);
94 dprintf(("time: %d-%d-%d %d:%d:%d", lpSystemTime->wDay, lpSystemTime->wMonth, lpSystemTime->wYear, lpSystemTime->wHour, lpSystemTime->wMinute, lpSystemTime->wSecond));
95 return ret;
96}
97//******************************************************************************
98//MS-DOS date & time values (UTC) to File time (also UTC)
99//******************************************************************************
100BOOL WIN32API DosDateTimeToFileTime(WORD wDosDate, WORD wDosTime, LPFILETIME pFileTime)
101{
102 dprintf(("%x %x", wDosDate, wDosTime));
103
104 if(pFileTime == NULL) {
105 SetLastError(ERROR_INVALID_PARAMETER);
106 return FALSE;
107 }
108 return O32_DosDateTimeToFileTime(wDosDate, wDosTime, pFileTime);
109}
110//******************************************************************************
111//******************************************************************************
112DWORD WIN32API GetTickCount(void)
113{
114 return OSLibDosGetTickCount();
115}
116//******************************************************************************
117//The GetLocalTime function retrieves the current local date and time.
118//(in local time)
119//******************************************************************************
120void WIN32API GetLocalTime(LPSYSTEMTIME lpLocalTime)
121{
122 if(lpLocalTime == NULL)
123 {
124 SetLastError(ERROR_INVALID_PARAMETER);
125 return;
126 }
127 O32_GetLocalTime(lpLocalTime);
128}
129//******************************************************************************
130//The SetLocalTime function sets the current local time and date.
131//(in local time)
132//******************************************************************************
133BOOL WIN32API SetLocalTime(const SYSTEMTIME *lpLocalTime)
134{
135 if(lpLocalTime == NULL)
136 {
137 SetLastError(ERROR_INVALID_PARAMETER);
138 return FALSE;
139 }
140 return O32_SetLocalTime(lpLocalTime);
141}
142//******************************************************************************
143//The GetSystemTime function retrieves the current system date and time.
144//The system time is expressed in Coordinated Universal Time (UTC).
145//******************************************************************************
146void WIN32API GetSystemTime(LPSYSTEMTIME lpSystemTime)
147{
148 if(lpSystemTime == NULL)
149 {
150 SetLastError(ERROR_INVALID_PARAMETER);
151 return;
152 }
153 O32_GetSystemTime(lpSystemTime);
154}
155//******************************************************************************
156//The SetSystemTime function sets the current system time and date.
157//The system time is expressed in Coordinated Universal Time (UCT).
158//******************************************************************************
159BOOL WIN32API SetSystemTime(const SYSTEMTIME *lpSystemTime)
160{
161 if(lpSystemTime == NULL)
162 {
163 SetLastError(ERROR_INVALID_PARAMETER);
164 return FALSE;
165 }
166 return O32_SetSystemTime(lpSystemTime);
167}
168//******************************************************************************
169//System time (UTC) to File time (UTC)
170//******************************************************************************
171BOOL WIN32API SystemTimeToFileTime(const SYSTEMTIME *lpSystemTime, LPFILETIME lpFileTime)
172{
173 return O32_SystemTimeToFileTime(lpSystemTime, lpFileTime);
174}
175//******************************************************************************
176//******************************************************************************
177BOOL WIN32API SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION lpTimeZone,
178 LPSYSTEMTIME lpSystemTime,
179 LPSYSTEMTIME lpLocalTime)
180{
181 return O32_SystemTimeToTzSpecificLocalTime(lpTimeZone, lpSystemTime, lpLocalTime);
182}
183//******************************************************************************
184//******************************************************************************
185DWORD WIN32API GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZone)
186{
187 return O32_GetTimeZoneInformation(lpTimeZone);
188}
189//******************************************************************************
190//******************************************************************************
191BOOL WIN32API SetTimeZoneInformation(const LPTIME_ZONE_INFORMATION lpTimeZone)
192{
193 return O32_SetTimeZoneInformation(lpTimeZone);
194}
195/*****************************************************************************
196 * Name : DWORD GetSystemTimeAsFileTime
197 * Purpose : The GetSystemTimeAsFileTime function obtains the current system
198 * date and time. The information is in Coordinated Universal Time (UCT) format.
199 * Parameters: LLPFILETIME lLPSYSTEMTIMEAsFileTime
200 * Variables :
201 * Result :
202 * Remark :
203 * Status : UNTESTED
204 *
205 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
206 *****************************************************************************/
207
208VOID WIN32API GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime)
209{
210 FILETIME ft; /* code sequence from WIN32.HLP */
211 SYSTEMTIME st;
212
213 GetSystemTime(&st);
214 SystemTimeToFileTime(&st, &ft);
215}
216//******************************************************************************
217//******************************************************************************
218
Note: See TracBrowser for help on using the repository browser.