| 1 | /* $Id: time.cpp,v 1.16 2001-07-20 15:33:30 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 "unicode.h"
|
|---|
| 34 |
|
|---|
| 35 | #define DBG_LOCALLOG DBG_time
|
|---|
| 36 | #include "dbglocal.h"
|
|---|
| 37 |
|
|---|
| 38 | /*****************************************************************************
|
|---|
| 39 | * Defines *
|
|---|
| 40 | *****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | ODINDEBUGCHANNEL(KERNEL32-TIME)
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | #define lstrcpynAtoW(unicode,ascii,asciilen) AsciiToUnicodeN(ascii,unicode,asciilen);
|
|---|
| 47 |
|
|---|
| 48 | #define WPRINTF_LEFTALIGN 0x0001 /* Align output on the left ('-' prefix) */
|
|---|
| 49 | #define WPRINTF_PREFIX_HEX 0x0002 /* Prefix hex with 0x ('#' prefix) */
|
|---|
| 50 | #define WPRINTF_ZEROPAD 0x0004 /* Pad with zeros ('0' prefix) */
|
|---|
| 51 | #define WPRINTF_LONG 0x0008 /* Long arg ('l' prefix) */
|
|---|
| 52 | #define WPRINTF_SHORT 0x0010 /* Short arg ('h' prefix) */
|
|---|
| 53 | #define WPRINTF_UPPER_HEX 0x0020 /* Upper-case hex ('X' specifier) */
|
|---|
| 54 | #define WPRINTF_WIDE 0x0040 /* Wide arg ('w' prefix) */
|
|---|
| 55 |
|
|---|
| 56 | typedef enum
|
|---|
| 57 | {
|
|---|
| 58 | WPR_UNKNOWN,
|
|---|
| 59 | WPR_CHAR,
|
|---|
| 60 | WPR_WCHAR,
|
|---|
| 61 | WPR_STRING,
|
|---|
| 62 | WPR_WSTRING,
|
|---|
| 63 | WPR_SIGNED,
|
|---|
| 64 | WPR_UNSIGNED,
|
|---|
| 65 | WPR_HEXA
|
|---|
| 66 | } WPRINTF_TYPE;
|
|---|
| 67 |
|
|---|
| 68 | typedef struct
|
|---|
| 69 | {
|
|---|
| 70 | UINT flags;
|
|---|
| 71 | UINT width;
|
|---|
| 72 | UINT precision;
|
|---|
| 73 | WPRINTF_TYPE type;
|
|---|
| 74 | } WPRINTF_FORMAT;
|
|---|
| 75 |
|
|---|
| 76 | typedef union {
|
|---|
| 77 | WCHAR wchar_view;
|
|---|
| 78 | CHAR char_view;
|
|---|
| 79 | LPCSTR lpcstr_view;
|
|---|
| 80 | LPCWSTR lpcwstr_view;
|
|---|
| 81 | INT int_view;
|
|---|
| 82 | } WPRINTF_DATA;
|
|---|
| 83 |
|
|---|
| 84 | static const CHAR null_stringA[] = "(null)";
|
|---|
| 85 | static const WCHAR null_stringW[] = { '(', 'n', 'u', 'l', 'l', ')', 0 };
|
|---|
| 86 |
|
|---|
| 87 | //******************************************************************************
|
|---|
| 88 | //******************************************************************************
|
|---|
| 89 | ODINPROCEDURE1(GetLocalTime,
|
|---|
| 90 | LPSYSTEMTIME, arg1)
|
|---|
| 91 | {
|
|---|
| 92 | O32_GetLocalTime(arg1);
|
|---|
| 93 | }
|
|---|
| 94 | //******************************************************************************
|
|---|
| 95 | //******************************************************************************
|
|---|
| 96 | ODINFUNCTION1(BOOL, SetLocalTime,
|
|---|
| 97 | const SYSTEMTIME *, arg1)
|
|---|
| 98 | {
|
|---|
| 99 | return O32_SetLocalTime(arg1);
|
|---|
| 100 | }
|
|---|
| 101 | //******************************************************************************
|
|---|
| 102 | //******************************************************************************
|
|---|
| 103 | ODINFUNCTION3(BOOL,FileTimeToDosDateTime,
|
|---|
| 104 | const FILETIME *, arg1,
|
|---|
| 105 | LPWORD, arg2,
|
|---|
| 106 | LPWORD, arg3)
|
|---|
| 107 | {
|
|---|
| 108 | return O32_FileTimeToDosDateTime(arg1, arg2, arg3);
|
|---|
| 109 | }
|
|---|
| 110 | //******************************************************************************
|
|---|
| 111 | //******************************************************************************
|
|---|
| 112 | BOOL WIN32API FileTimeToLocalFileTime(const FILETIME * arg1, LPFILETIME arg2)
|
|---|
| 113 | {
|
|---|
| 114 | dprintf(("KERNEL32: FileTimeToLocalFileTime\n"));
|
|---|
| 115 | return O32_FileTimeToLocalFileTime(arg1, arg2);
|
|---|
| 116 | }
|
|---|
| 117 | //******************************************************************************
|
|---|
| 118 | //******************************************************************************
|
|---|
| 119 | BOOL WIN32API LocalFileTimeToFileTime(const FILETIME * arg1, LPFILETIME arg2)
|
|---|
| 120 | {
|
|---|
| 121 | dprintf(("KERNEL32: LocalFileTimeToFileTime\n"));
|
|---|
| 122 | return O32_LocalFileTimeToFileTime(arg1, arg2);
|
|---|
| 123 | }
|
|---|
| 124 | //******************************************************************************
|
|---|
| 125 | //******************************************************************************
|
|---|
| 126 | ODINFUNCTION2(BOOL, FileTimeToSystemTime,
|
|---|
| 127 | const FILETIME *, arg1,
|
|---|
| 128 | LPSYSTEMTIME, arg2)
|
|---|
| 129 | {
|
|---|
| 130 | return O32_FileTimeToSystemTime(arg1, arg2);
|
|---|
| 131 | }
|
|---|
| 132 | //******************************************************************************
|
|---|
| 133 | //******************************************************************************
|
|---|
| 134 | ODINFUNCTION3(BOOL,DosDateTimeToFileTime,
|
|---|
| 135 | WORD, arg1,
|
|---|
| 136 | WORD, arg2,
|
|---|
| 137 | LPFILETIME, arg3)
|
|---|
| 138 | {
|
|---|
| 139 | return O32_DosDateTimeToFileTime(arg1, arg2, arg3);
|
|---|
| 140 | }
|
|---|
| 141 | //******************************************************************************
|
|---|
| 142 | //******************************************************************************
|
|---|
| 143 | ODINFUNCTION1(DWORD, GetTimeZoneInformation,
|
|---|
| 144 | LPTIME_ZONE_INFORMATION, arg1)
|
|---|
| 145 | {
|
|---|
| 146 | return O32_GetTimeZoneInformation(arg1);
|
|---|
| 147 | }
|
|---|
| 148 | //******************************************************************************
|
|---|
| 149 | //******************************************************************************
|
|---|
| 150 | DWORD WIN32API GetTickCount(void)
|
|---|
| 151 | {
|
|---|
| 152 | //// dprintf(("KERNEL32: GetTickCount\n"));
|
|---|
| 153 | return O32_GetTickCount();
|
|---|
| 154 | }
|
|---|
| 155 | //******************************************************************************
|
|---|
| 156 | //******************************************************************************
|
|---|
| 157 | ODINPROCEDURE1(GetSystemTime,
|
|---|
| 158 | LPSYSTEMTIME, arg1)
|
|---|
| 159 | {
|
|---|
| 160 | O32_GetSystemTime(arg1);
|
|---|
| 161 | }
|
|---|
| 162 | //******************************************************************************
|
|---|
| 163 | //******************************************************************************
|
|---|
| 164 | ODINFUNCTION2(BOOL, SystemTimeToFileTime,
|
|---|
| 165 | const SYSTEMTIME *, arg1,
|
|---|
| 166 | LPFILETIME, arg2)
|
|---|
| 167 | {
|
|---|
| 168 | return O32_SystemTimeToFileTime(arg1, arg2);
|
|---|
| 169 | }
|
|---|
| 170 | //******************************************************************************
|
|---|
| 171 | //******************************************************************************
|
|---|
| 172 | ODINFUNCTION3(BOOL, SystemTimeToTzSpecificLocalTime,
|
|---|
| 173 | LPTIME_ZONE_INFORMATION, arg1,
|
|---|
| 174 | LPSYSTEMTIME, arg2,
|
|---|
| 175 | LPSYSTEMTIME, arg3)
|
|---|
| 176 | {
|
|---|
| 177 | return O32_SystemTimeToTzSpecificLocalTime(arg1, arg2, arg3);
|
|---|
| 178 | }
|
|---|
| 179 | //******************************************************************************
|
|---|
| 180 | //******************************************************************************
|
|---|
| 181 | ODINFUNCTION1(BOOL, SetTimeZoneInformation,
|
|---|
| 182 | const LPTIME_ZONE_INFORMATION, arg1)
|
|---|
| 183 | {
|
|---|
| 184 | return O32_SetTimeZoneInformation(arg1);
|
|---|
| 185 | }
|
|---|
| 186 | //******************************************************************************
|
|---|
| 187 | //******************************************************************************
|
|---|
| 188 | ODINFUNCTION1(BOOL,SetSystemTime,
|
|---|
| 189 | const SYSTEMTIME *, arg1)
|
|---|
| 190 | {
|
|---|
| 191 | return O32_SetSystemTime(arg1);
|
|---|
| 192 | }
|
|---|
| 193 | /*****************************************************************************
|
|---|
| 194 | * Name : DWORD GetSystemTimeAsFileTime
|
|---|
| 195 | * Purpose : The GetSystemTimeAsFileTime function obtains the current system
|
|---|
| 196 | * date and time. The information is in Coordinated Universal Time (UTC) format.
|
|---|
| 197 | * Parameters: LLPFILETIME lLPSYSTEMTIMEAsFileTime
|
|---|
| 198 | * Variables :
|
|---|
| 199 | * Result :
|
|---|
| 200 | * Remark :
|
|---|
| 201 | * Status : UNTESTED
|
|---|
| 202 | *
|
|---|
| 203 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 204 | *****************************************************************************/
|
|---|
| 205 |
|
|---|
| 206 | VOID WIN32API GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime)
|
|---|
| 207 | {
|
|---|
| 208 | FILETIME ft; /* code sequence from WIN32.HLP */
|
|---|
| 209 | SYSTEMTIME st;
|
|---|
| 210 |
|
|---|
| 211 | dprintf(("KERNEL32: GetSystemTimeAsFileTime(%08xh)\n", lpSystemTimeAsFileTime));
|
|---|
| 212 |
|
|---|
| 213 | GetSystemTime(&st);
|
|---|
| 214 | SystemTimeToFileTime(&st, &ft);
|
|---|
| 215 | }
|
|---|