| 1 | /* $Id: time.cpp,v 1.17 2002-02-09 17:27:32 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 | void WIN32API GetLocalTime(LPSYSTEMTIME arg1)
|
|---|
| 90 | {
|
|---|
| 91 | O32_GetLocalTime(arg1);
|
|---|
| 92 | }
|
|---|
| 93 | //******************************************************************************
|
|---|
| 94 | //******************************************************************************
|
|---|
| 95 | BOOL WIN32API SetLocalTime(const SYSTEMTIME * arg1)
|
|---|
| 96 | {
|
|---|
| 97 | return O32_SetLocalTime(arg1);
|
|---|
| 98 | }
|
|---|
| 99 | //******************************************************************************
|
|---|
| 100 | //******************************************************************************
|
|---|
| 101 | BOOL WIN32API FileTimeToDosDateTime(const FILETIME * arg1, LPWORD arg2,
|
|---|
| 102 | LPWORD arg3)
|
|---|
| 103 | {
|
|---|
| 104 | return O32_FileTimeToDosDateTime(arg1, arg2, arg3);
|
|---|
| 105 | }
|
|---|
| 106 | //******************************************************************************
|
|---|
| 107 | //******************************************************************************
|
|---|
| 108 | BOOL WIN32API FileTimeToLocalFileTime(const FILETIME * arg1, LPFILETIME arg2)
|
|---|
| 109 | {
|
|---|
| 110 | dprintf(("KERNEL32: FileTimeToLocalFileTime\n"));
|
|---|
| 111 | return O32_FileTimeToLocalFileTime(arg1, arg2);
|
|---|
| 112 | }
|
|---|
| 113 | //******************************************************************************
|
|---|
| 114 | //******************************************************************************
|
|---|
| 115 | BOOL WIN32API LocalFileTimeToFileTime(const FILETIME * arg1, LPFILETIME arg2)
|
|---|
| 116 | {
|
|---|
| 117 | dprintf(("KERNEL32: LocalFileTimeToFileTime\n"));
|
|---|
| 118 | return O32_LocalFileTimeToFileTime(arg1, arg2);
|
|---|
| 119 | }
|
|---|
| 120 | //******************************************************************************
|
|---|
| 121 | //******************************************************************************
|
|---|
| 122 | BOOL WIN32API FileTimeToSystemTime(const FILETIME * arg1, LPSYSTEMTIME arg2)
|
|---|
| 123 | {
|
|---|
| 124 | return O32_FileTimeToSystemTime(arg1, arg2);
|
|---|
| 125 | }
|
|---|
| 126 | //******************************************************************************
|
|---|
| 127 | //******************************************************************************
|
|---|
| 128 | BOOL WIN32API DosDateTimeToFileTime(WORD arg1, WORD arg2, LPFILETIME arg3)
|
|---|
| 129 | {
|
|---|
| 130 | return O32_DosDateTimeToFileTime(arg1, arg2, arg3);
|
|---|
| 131 | }
|
|---|
| 132 | //******************************************************************************
|
|---|
| 133 | //******************************************************************************
|
|---|
| 134 | DWORD WIN32API GetTimeZoneInformation(LPTIME_ZONE_INFORMATION arg1)
|
|---|
| 135 | {
|
|---|
| 136 | return O32_GetTimeZoneInformation(arg1);
|
|---|
| 137 | }
|
|---|
| 138 | //******************************************************************************
|
|---|
| 139 | //******************************************************************************
|
|---|
| 140 | DWORD WIN32API GetTickCount(void)
|
|---|
| 141 | {
|
|---|
| 142 | //// dprintf(("KERNEL32: GetTickCount\n"));
|
|---|
| 143 | return O32_GetTickCount();
|
|---|
| 144 | }
|
|---|
| 145 | //******************************************************************************
|
|---|
| 146 | //******************************************************************************
|
|---|
| 147 | void WIN32API GetSystemTime(LPSYSTEMTIME arg1)
|
|---|
| 148 | {
|
|---|
| 149 | O32_GetSystemTime(arg1);
|
|---|
| 150 | }
|
|---|
| 151 | //******************************************************************************
|
|---|
| 152 | //******************************************************************************
|
|---|
| 153 | BOOL WIN32API SystemTimeToFileTime(const SYSTEMTIME * arg1,
|
|---|
| 154 | LPFILETIME arg2)
|
|---|
| 155 | {
|
|---|
| 156 | return O32_SystemTimeToFileTime(arg1, arg2);
|
|---|
| 157 | }
|
|---|
| 158 | //******************************************************************************
|
|---|
| 159 | //******************************************************************************
|
|---|
| 160 | BOOL WIN32API SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION arg1,
|
|---|
| 161 | LPSYSTEMTIME arg2,
|
|---|
| 162 | LPSYSTEMTIME arg3)
|
|---|
| 163 | {
|
|---|
| 164 | return O32_SystemTimeToTzSpecificLocalTime(arg1, arg2, arg3);
|
|---|
| 165 | }
|
|---|
| 166 | //******************************************************************************
|
|---|
| 167 | //******************************************************************************
|
|---|
| 168 | BOOL WIN32API SetTimeZoneInformation(const LPTIME_ZONE_INFORMATION arg1)
|
|---|
| 169 | {
|
|---|
| 170 | return O32_SetTimeZoneInformation(arg1);
|
|---|
| 171 | }
|
|---|
| 172 | //******************************************************************************
|
|---|
| 173 | //******************************************************************************
|
|---|
| 174 | BOOL WIN32API SetSystemTime(const SYSTEMTIME * arg1)
|
|---|
| 175 | {
|
|---|
| 176 | return O32_SetSystemTime(arg1);
|
|---|
| 177 | }
|
|---|
| 178 | /*****************************************************************************
|
|---|
| 179 | * Name : DWORD GetSystemTimeAsFileTime
|
|---|
| 180 | * Purpose : The GetSystemTimeAsFileTime function obtains the current system
|
|---|
| 181 | * date and time. The information is in Coordinated Universal Time (UTC) format.
|
|---|
| 182 | * Parameters: LLPFILETIME lLPSYSTEMTIMEAsFileTime
|
|---|
| 183 | * Variables :
|
|---|
| 184 | * Result :
|
|---|
| 185 | * Remark :
|
|---|
| 186 | * Status : UNTESTED
|
|---|
| 187 | *
|
|---|
| 188 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 189 | *****************************************************************************/
|
|---|
| 190 |
|
|---|
| 191 | VOID WIN32API GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime)
|
|---|
| 192 | {
|
|---|
| 193 | FILETIME ft; /* code sequence from WIN32.HLP */
|
|---|
| 194 | SYSTEMTIME st;
|
|---|
| 195 |
|
|---|
| 196 | dprintf(("KERNEL32: GetSystemTimeAsFileTime(%08xh)\n", lpSystemTimeAsFileTime));
|
|---|
| 197 |
|
|---|
| 198 | GetSystemTime(&st);
|
|---|
| 199 | SystemTimeToFileTime(&st, &ft);
|
|---|
| 200 | }
|
|---|