Ignore:
Timestamp:
Jun 26, 2002, 12:18:27 PM (23 years ago)
Author:
sandervl
Message:

minor updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/time.cpp

    r8777 r8780  
    1 /* $Id: time.cpp,v 1.21 2002-06-26 07:42:35 sandervl Exp $ */
     1/* $Id: time.cpp,v 1.22 2002-06-26 10:18:27 sandervl Exp $ */
    22
    33/*
    44 * Win32 time/date API functions
    55 *
    6  * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
     6 * Copyright 1998-2002 Sander van Leeuwen (sandervl@xs4all.nl)
    77 * Copyright 1999 Christoph Bratschi (cbratschi@datacomm.ch)
    88 *
    9  * Copyright 1996 Alexandre Julliard
    10  * Copyright 1995 Martin von Loewis
    11  * Copyright 1998 David Lee Lambert
    12 
    139 *
    1410 * Project Odin Software License can be found in LICENSE.TXT
     
    3329#include <time.h>
    3430#include "unicode.h"
     31#include "oslibtime.h"
    3532
    3633#define DBG_LOCALLOG    DBG_time
    3734#include "dbglocal.h"
    3835
    39 //******************************************************************************
    40 //******************************************************************************
    41 void WIN32API GetLocalTime(LPSYSTEMTIME arg1)
    42 {
    43   O32_GetLocalTime(arg1);
    44 }
    45 //******************************************************************************
    46 //******************************************************************************
    47 BOOL WIN32API SetLocalTime(const SYSTEMTIME * arg1)
    48 {
    49   return O32_SetLocalTime(arg1);
    50 }
    51 //******************************************************************************
    52 //******************************************************************************
    53 BOOL WIN32API FileTimeToDosDateTime(const FILETIME * arg1,  LPWORD arg2,
    54                                     LPWORD arg3)
    55 {
    56     return O32_FileTimeToDosDateTime(arg1, arg2, arg3);
    57 }
    58 
    59 //******************************************************************************
    60 //******************************************************************************
    61 BOOL WIN32API FileTimeToLocalFileTime(const FILETIME * utcft, LPFILETIME localft)
    62 {
    63    return O32_FileTimeToLocalFileTime(utcft,localft);
    64 }
    65 //******************************************************************************
    66 //******************************************************************************
    67 BOOL WIN32API LocalFileTimeToFileTime(const FILETIME * arg1, LPFILETIME arg2)
    68 {
    69     dprintf(("KERNEL32:  LocalFileTimeToFileTime\n"));
    70     return O32_LocalFileTimeToFileTime(arg1, arg2);
    71 }
    72 //******************************************************************************
    73 //******************************************************************************
    74 BOOL WIN32API FileTimeToSystemTime(const FILETIME * arg1, LPSYSTEMTIME arg2)
    75 {
    76    return O32_FileTimeToSystemTime(arg1, arg2);
    77 }
    78 //******************************************************************************
    79 //******************************************************************************
    80 BOOL WIN32API DosDateTimeToFileTime(WORD arg1, WORD arg2, LPFILETIME arg3)
    81 {
    82     return O32_DosDateTimeToFileTime(arg1, arg2, arg3);
    83 }
    84 //******************************************************************************
    85 //******************************************************************************
    86 DWORD WIN32API GetTimeZoneInformation(LPTIME_ZONE_INFORMATION arg1)
    87 {
    88     return O32_GetTimeZoneInformation(arg1);
     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);
    89109}
    90110//******************************************************************************
     
    92112DWORD WIN32API GetTickCount(void)
    93113{
    94 ////    dprintf(("KERNEL32:  GetTickCount\n"));
    95     return O32_GetTickCount();
    96 }
    97 //******************************************************************************
    98 //******************************************************************************
    99 void WIN32API GetSystemTime(LPSYSTEMTIME arg1)
    100 {
    101     O32_GetSystemTime(arg1);
    102 }
    103 //******************************************************************************
    104 //******************************************************************************
    105 BOOL WIN32API SystemTimeToFileTime(const SYSTEMTIME * arg1,
    106                                    LPFILETIME arg2)
    107 {
    108     return O32_SystemTimeToFileTime(arg1, arg2);
    109 }
    110 //******************************************************************************
    111 //******************************************************************************
    112 BOOL WIN32API SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION arg1,
    113                                               LPSYSTEMTIME arg2,
    114                                               LPSYSTEMTIME arg3)
    115 {
    116   return O32_SystemTimeToTzSpecificLocalTime(arg1, arg2, arg3);
    117 }
    118 //******************************************************************************
    119 //******************************************************************************
    120 BOOL WIN32API SetTimeZoneInformation(const LPTIME_ZONE_INFORMATION arg1)
    121 {
    122   return O32_SetTimeZoneInformation(arg1);
    123 }
    124 //******************************************************************************
    125 //******************************************************************************
    126 BOOL WIN32API SetSystemTime(const SYSTEMTIME * arg1)
    127 {
    128   return O32_SetSystemTime(arg1);
     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);
    129194}
    130195/*****************************************************************************
    131196 * Name      : DWORD GetSystemTimeAsFileTime
    132197 * Purpose   : The GetSystemTimeAsFileTime function obtains the current system
    133  *             date and time. The information is in Coordinated Universal Time (UTC) format.
     198 *             date and time. The information is in Coordinated Universal Time (UCT) format.
    134199 * Parameters: LLPFILETIME lLPSYSTEMTIMEAsFileTime
    135200 * Variables :
     
    143208VOID WIN32API GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime)
    144209{
    145  FILETIME   ft;                             /* code sequence from WIN32.HLP */
    146  SYSTEMTIME st;
    147 
    148   dprintf(("KERNEL32: GetSystemTimeAsFileTime(%08xh)\n", lpSystemTimeAsFileTime));
    149 
    150   GetSystemTime(&st);
    151   SystemTimeToFileTime(&st, &ft);
    152 }
     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 TracChangeset for help on using the changeset viewer.