diff --git a/reactos/lib/sdk/crt/crt.rbuild b/reactos/lib/sdk/crt/crt.rbuild index 1d81724f1ef..5f6f7ba2500 100644 --- a/reactos/lib/sdk/crt/crt.rbuild +++ b/reactos/lib/sdk/crt/crt.rbuild @@ -291,6 +291,11 @@ lfind.c lsearch.c + + getinvp.c + invalidp.c + setinvp.c + @@ -437,7 +442,7 @@ systime.c - + + + asctime.c + clock.c + ctime32.c + ctime64.c + ctime.c + difftime32.c + difftime64.c + difftime.c + ftime32.c + ftime64.c + ftime.c + futime32.c + futime64.c + futime.c + gmtime.c + localtime32.c + localtime64.c + localtime.c + mktime.c + strdate.c + strftime.c + strtime.c + time32.c + time64.c + time.c + timezone.c + utime32.c + utime64.c + utime.c + wasctime.c + wctime32.c + wctime64.c + wctime.c + wutime32.c + wutime64.c + wutime.c + wcsftime.c + wstrdate.c + wstrtime.c + wcscoll.c wcscspn.c diff --git a/reactos/lib/sdk/crt/include/internal/file.h b/reactos/lib/sdk/crt/include/internal/file.h index 86915b5f149..5f1064ac474 100644 --- a/reactos/lib/sdk/crt/include/internal/file.h +++ b/reactos/lib/sdk/crt/include/internal/file.h @@ -48,8 +48,8 @@ char __fileno_getmode(int _fd); int __fileno_setmode(int _fd, int _newmode); void sigabort_handler(int sig); -void UnixTimeToFileTime(time_t unix_time, FILETIME* filetime, DWORD remainder); -time_t FileTimeToUnixTime(const FILETIME* filetime, DWORD *remainder); +//void UnixTimeToFileTime(time_t unix_time, FILETIME* filetime, DWORD remainder); +//time_t FileTimeToUnixTime(const FILETIME* filetime, DWORD *remainder); #define __FILE_REC_MAX 20 diff --git a/reactos/lib/sdk/crt/include/internal/safecrt.h b/reactos/lib/sdk/crt/include/internal/safecrt.h new file mode 100644 index 00000000000..fea4edd6584 --- /dev/null +++ b/reactos/lib/sdk/crt/include/internal/safecrt.h @@ -0,0 +1,10 @@ + +extern void * __pInvalidArgHandler; + +void _invalid_parameter( + const wchar_t * expression, + const wchar_t * function, + const wchar_t * file, + unsigned int line, + uintptr_t pReserved); + diff --git a/reactos/lib/sdk/crt/include/internal/time.h b/reactos/lib/sdk/crt/include/internal/time.h new file mode 100644 index 00000000000..e58a506a120 --- /dev/null +++ b/reactos/lib/sdk/crt/include/internal/time.h @@ -0,0 +1,56 @@ + +#define DIFFTIME 0x19db1ded53e8000ULL +#define DIFFDAYS (3 * DAYSPER100YEARS + 17 * DAYSPER4YEARS + 1 * DAYSPERYEAR) + +#define DAYSPERYEAR 365 +#define DAYSPER4YEARS (4*DAYSPERYEAR+1) +#define DAYSPER100YEARS (25*DAYSPER4YEARS-1) +#define DAYSPER400YEARS (4*DAYSPER100YEARS+1) +#define SECONDSPERDAY (24*60*60) +#define SECONDSPERHOUR (60*60) +#define LEAPDAY 59 + +extern inline +__time64_t +FileTimeToUnixTime(const FILETIME *FileTime, USHORT *millitm) +{ + ULARGE_INTEGER ULargeInt; + __time64_t time; + + ULargeInt.LowPart = FileTime->dwLowDateTime; + ULargeInt.HighPart = FileTime->dwHighDateTime; + ULargeInt.QuadPart -= DIFFTIME; + + time = ULargeInt.QuadPart / 10000; + if (millitm) + *millitm = (ULargeInt.QuadPart % 10000) / 10; + + return time; +} + +static __inline +long leapyears_passed(long days) +{ + long quadcenturies, centuries, quadyears; + quadcenturies = days / DAYSPER400YEARS; + days -= quadcenturies; + centuries = days / DAYSPER100YEARS; + days += centuries; + quadyears = days / DAYSPER4YEARS; + return quadyears - centuries + quadcenturies; +} + +static __inline +long leapdays_passed(long days) +{ + return leapyears_passed(days + DAYSPERYEAR - LEAPDAY + 1); +} + +static __inline +long years_passed(long days) +{ + return (days - leapdays_passed(days)) / 365; +} + +extern long dst_begin; +extern long dst_end; diff --git a/reactos/lib/sdk/crt/include/internal/tls.h b/reactos/lib/sdk/crt/include/internal/tls.h index 9908260b91d..57986d274ab 100644 --- a/reactos/lib/sdk/crt/include/internal/tls.h +++ b/reactos/lib/sdk/crt/include/internal/tls.h @@ -28,6 +28,10 @@ typedef struct _ThreadData int fpecode; /* fp exception code */ EXCEPTION_RECORD *exc_record; /* Head of exception record list */ + + struct tm tmbuf; /* Used by gmtime, mktime, mkgmtime, localtime */ + char asctimebuf[26]; /* Buffer for asctime and ctime */ + wchar_t wasctimebuf[26]; /* Buffer for wasctime and wctime */ } THREADDATA, *PTHREADDATA; diff --git a/reactos/lib/sdk/crt/misc/tls.c b/reactos/lib/sdk/crt/misc/tls.c index 71723211106..3c48a9104d9 100644 --- a/reactos/lib/sdk/crt/misc/tls.c +++ b/reactos/lib/sdk/crt/misc/tls.c @@ -16,6 +16,10 @@ static void InitThreadData(PTHREADDATA ThreadData) ThreadData->tnext = 1; + memset(&ThreadData->tmbuf, sizeof(struct tm), 0); + memset(&ThreadData->asctimebuf, 26 * sizeof(char), 0); + memset(&ThreadData->wasctimebuf, 26 * sizeof(wchar_t), 0); + /* FIXME: init more thread local data */ } diff --git a/reactos/lib/sdk/crt/precomp.h b/reactos/lib/sdk/crt/precomp.h index 0d8afa002cf..27984e6fc0f 100644 --- a/reactos/lib/sdk/crt/precomp.h +++ b/reactos/lib/sdk/crt/precomp.h @@ -59,5 +59,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); #include #include #include +#include +#include #endif /* _CRT_PRECOMP_H */ diff --git a/reactos/lib/sdk/crt/securecrt/getinvp.c b/reactos/lib/sdk/crt/securecrt/getinvp.c new file mode 100644 index 00000000000..356eaa6843d --- /dev/null +++ b/reactos/lib/sdk/crt/securecrt/getinvp.c @@ -0,0 +1,17 @@ +#include + +_invalid_parameter_handler +_get_invalid_parameter_handler(void) +{ + _invalid_parameter_handler oldhandler; + + if (__pInvalidArgHandler) + { + oldhandler = DecodePointer(__pInvalidArgHandler); + } + else + { + oldhandler = NULL; + } + return oldhandler; +} diff --git a/reactos/lib/sdk/crt/securecrt/invalidp.c b/reactos/lib/sdk/crt/securecrt/invalidp.c new file mode 100644 index 00000000000..f26174e179a --- /dev/null +++ b/reactos/lib/sdk/crt/securecrt/invalidp.c @@ -0,0 +1,47 @@ +#include + +void * __pInvalidArgHandler = NULL; + +void +_invalid_parameter_default( + const wchar_t * expression, + const wchar_t * function, + const wchar_t * file, + unsigned int line, + uintptr_t pReserved) +{ + // TODO: launch Doc Watson or something like that + UNIMPLEMENTED; + ExitProcess(-1); +} + + +// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=98835 +void +_invalid_parameter( + const wchar_t * expression, + const wchar_t * function, + const wchar_t * file, + unsigned int line, + uintptr_t pReserved) +{ + _invalid_parameter_handler handler; + + if (__pInvalidArgHandler) + { + handler = DecodePointer(__pInvalidArgHandler); + } + else + { + handler = _invalid_parameter_default; + } + handler(expression, function, file, line, pReserved); +} + +// http://cowboyprogramming.com/2007/02/22/what-is-_invalid_parameter_noinfo-and-how-do-i-get-rid-of-it/ +void +invalid_parameter_noinfo(void) +{ + _invalid_parameter(0, 0, 0, 0, 0); +} + diff --git a/reactos/lib/sdk/crt/securecrt/setinvp.c b/reactos/lib/sdk/crt/securecrt/setinvp.c new file mode 100644 index 00000000000..0799648de71 --- /dev/null +++ b/reactos/lib/sdk/crt/securecrt/setinvp.c @@ -0,0 +1,27 @@ +#include + +_invalid_parameter_handler +_set_invalid_parameter_handler(_invalid_parameter_handler newhandler) +{ + _invalid_parameter_handler oldhandler; + + if (__pInvalidArgHandler) + { + oldhandler = DecodePointer(__pInvalidArgHandler); + } + else + { + oldhandler = NULL; + } + + if (newhandler) + { + __pInvalidArgHandler = EncodePointer(newhandler); + } + else + { + __pInvalidArgHandler = 0; + } + + return oldhandler; +} diff --git a/reactos/lib/sdk/crt/time_new/asctime.c b/reactos/lib/sdk/crt/time_new/asctime.c new file mode 100644 index 00000000000..4929ddfd49b --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/asctime.c @@ -0,0 +1,162 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/ftime.c + * PURPOSE: Implementation of asctime(), _asctime_s() + * PROGRAMERS: Timo Kreuzer + */ +#include +#include +#include +#include "bitsfixup.h" + +#define DAYSPERWEEK 7 +#define MONSPERYEAR 12 + +static const _TCHAR wday_name[DAYSPERWEEK][4] = +{ + _T("Sun "), _T("Mon "), _T("Tue "), _T("Wed "), + _T("Thu "), _T("Fri "), _T("Sat ") +}; + +static const _TCHAR mon_name[MONSPERYEAR][4] = +{ + _T("Jan "), _T("Feb "), _T("Mar "), _T("Apr "), _T("May "), _T("Jun "), + _T("Jul "), _T("Aug "), _T("Sep "), _T("Oct "), _T("Nov "), _T("Dec ") +}; + +#ifdef _UNICODE +typedef unsigned long long _TCHAR4; +typedef unsigned long _TCHAR2; +#else +typedef unsigned long _TCHAR4; +typedef unsigned short _TCHAR2; +#endif + +typedef union +{ + _TCHAR text[26]; + struct + { + _TCHAR4 WeekDay; + _TCHAR4 Month; + _TCHAR2 Day; + _TCHAR Space1; + _TCHAR2 Hour; + _TCHAR Sep1; + _TCHAR2 Minute; + _TCHAR Sep2; + _TCHAR2 Second; + _TCHAR Space2; + _TCHAR2 Year[2]; + _TCHAR lb; + _TCHAR zt; + }; +} timebuf_t; + +_TCHAR2 +static __inline__ +IntToChar2(int x) +{ + union + { + _TCHAR2 char2; + _TCHAR array[2]; + } u; + + u.array[0] = '0' + (x / 10); + u.array[1] = '0' + (x % 10); + + return u.char2; +} + +void +static __inline__ +FillBuf(timebuf_t *buf, const struct tm *ptm) +{ + /* Format looks like this: + * "Sun Mar 01 12:34:56 1902\n\0" */ + buf->WeekDay = *(_TCHAR4*)wday_name[ptm->tm_wday]; + buf->Month = *(_TCHAR4*)mon_name[ptm->tm_mon]; + buf->Day = IntToChar2(ptm->tm_mday); + buf->Space1 = ' '; + buf->Hour = IntToChar2(ptm->tm_mday); + buf->Sep1 = ':'; + buf->Minute = IntToChar2(ptm->tm_mday); + buf->Sep2 = ':'; + buf->Second = IntToChar2(ptm->tm_mday); + buf->Space2 = ' '; + buf->Year[0] = IntToChar2(ptm->tm_year / 100); + buf->Year[1] = IntToChar2(ptm->tm_year % 100); + buf->lb = '\n'; + buf->zt = '\0'; +} + +/****************************************************************************** + * \name _tasctime_s + * \brief Converts a local time into a string and returns a pointer to it. + * \param buffer Buffer that receives the string (26 characters). + * \param numberOfElements Size of the buffer in characters. + * \param time Pointer to the UTC time. + */ +errno_t +_tasctime_s( + _TCHAR* buffer, + size_t numberOfElements, + const struct tm *ptm) +{ + /* Validate parameters */ + if (!buffer || numberOfElements < 26 || !ptm || + (unsigned int)ptm->tm_sec > 59 || + (unsigned int)ptm->tm_min > 59 || + (unsigned int)ptm->tm_hour > 23 || + (unsigned int)ptm->tm_mday > 31 || + (unsigned int)ptm->tm_mon > 11 || + (unsigned int)ptm->tm_year > 2038 || + (unsigned int)ptm->tm_wday > 6 || + (unsigned int)ptm->tm_yday > 365) + { + _invalid_parameter(NULL, +#ifdef UNICODE + L"_wasctime", +#else + L"asctime", +#endif + _CRT_WIDE(__FILE__), + __LINE__, + 0); + return EINVAL; + } + + /* Fill the buffer */ + FillBuf((timebuf_t*)buffer, ptm); + + return 0; +} + +/****************************************************************************** + * \name _tasctime + * \brief Converts a UTC time into a string and returns a pointer to it. + * \param ptm Pointer to the UTC time. + * \remarks The string is stored in thread local buffer, shared between + * ctime, gmtime and localtime (32 and 64 bit versions). + */ +_TCHAR * +_tasctime(const struct tm *ptm) +{ + PTHREADDATA pThreadData; + _TCHAR *pstr; + + /* Get pointer to TLS buffer */ + pThreadData = GetThreadData(); +#ifndef _UNICODE + pstr = pThreadData->asctimebuf; +#else + pstr = pThreadData->wasctimebuf; +#endif + + /* Fill the buffer */ + FillBuf((timebuf_t*)pstr, ptm); + + return pstr; +} diff --git a/reactos/lib/sdk/crt/time_new/bitsfixup.h b/reactos/lib/sdk/crt/time_new/bitsfixup.h new file mode 100644 index 00000000000..196ff882dc2 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/bitsfixup.h @@ -0,0 +1,51 @@ + +#if defined(_USE_EXPLITIT_32BIT_TIME) || defined(_USE_EXPLITIT_64BIT_TIME) +#undef _timeb +#undef _ftime +#undef _tctime +#undef _ftime_s +#undef _tctime_s +#undef _tutime +#else +#define _time time +#endif + +#ifdef _USE_EXPLITIT_32BIT_TIME +#define time_t __time32_t +#define _timeb __timeb32 +#define _utimbuf __utimbuf32 + +#define difftime _difftime32 +#define localtime _localtime32 +#define localtime_s _localtime32_s +#define _time _time32 + +#define _ftime _ftime32 +#define _ftime_s _ftime32_s +#define _futime _futime32 +#define _tctime _tctime32 +#define _tctime_s _tctime32_s +#define _tutime _tutime32 +#define gmtime _gmtime32 + +#endif + +#ifdef _USE_EXPLITIT_64BIT_TIME +#define time_t __time64_t +#define _timeb __timeb64 +#define _utimbuf __utimbuf64 + +#define difftime _difftime64 +#define localtime _localtime64 +#define localtime_s _localtime64_s +#define _time _time64 + +#define _ftime _ftime64 +#define _ftime_s _ftime64_s +#define _futime _futime64 +#define _tctime _tctime64 +#define _tctime_s _tctime64_s +#define _tutime _tutime64 +#define gmtime _gmtime64 + +#endif diff --git a/reactos/lib/sdk/crt/time_new/clock.c b/reactos/lib/sdk/crt/time_new/clock.c new file mode 100644 index 00000000000..54cc7af88f5 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/clock.c @@ -0,0 +1,30 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/clock.c + * PURPOSE: Implementation of clock() + * PROGRAMER: Timo Kreuzer + */ +#include + +ULARGE_INTEGER g_StartupTime; + +void +initclock(void) +{ + GetSystemTimeAsFileTime((FILETIME*)&g_StartupTime); +} + +/****************************************************************************** + * \name clock + * \brief Returns the current process's elapsed time. + */ +clock_t +clock(void) +{ + ULARGE_INTEGER Time; + + GetSystemTimeAsFileTime((FILETIME*)&Time); + Time.QuadPart -= g_StartupTime.QuadPart; + return FileTimeToUnixTime((FILETIME*)&Time, NULL); +}; diff --git a/reactos/lib/sdk/crt/time_new/ctime.c b/reactos/lib/sdk/crt/time_new/ctime.c new file mode 100644 index 00000000000..0a4ff152fbc --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/ctime.c @@ -0,0 +1,52 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/ctime.c + * PURPOSE: Implementation of ctime, _ctime_s + * PROGRAMERS: Timo Kreuzer + */ +#define MINGW_HAS_SECURE_API 1 + +#include +#include +#include "bitsfixup.h" + +#define EINVAL -1 + +/****************************************************************************** + * \name _tctime_s + * \brief Converts a time_t value into a string. + * \param buffer Buffer that receives the string (26 characters). + * \param numberOfElements Size of the buffer in characters. + * \param time Pointer to the UTC time. + */ +errno_t +_tctime_s(_TCHAR *buffer, size_t numberOfElements, const time_t *time) +{ + struct tm _tm; + + if (localtime_s(&_tm, time) == EINVAL) + { + return EINVAL; + } + return _tasctime_s(buffer, numberOfElements, &_tm); +} + +/****************************************************************************** + * \name _tctime + * \brief Converts a time_t value into a string and returns a pointer to it. + * \param time Pointer to the UTC time. + * \remarks The string is stored in thread local buffer, shared between + * ctime, gmtime and localtime (both 32 and 64 bit versions). + */ +_TCHAR * +_tctime(const time_t *ptime) +{ + struct tm *ptm = localtime(ptime); + if (!ptm) + { + return 0; + } + return _tasctime(ptm); +} + diff --git a/reactos/lib/sdk/crt/time_new/ctime32.c b/reactos/lib/sdk/crt/time_new/ctime32.c new file mode 100644 index 00000000000..51abdee2dcd --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/ctime32.c @@ -0,0 +1,9 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/ctime32.c + * PURPOSE: Implementation of _ctime32() + * PROGRAMERS: Timo Kreuzer + */ +#define _USE_EXPLITIT_32BIT_TIME +#include "ctime.c" diff --git a/reactos/lib/sdk/crt/time_new/ctime64.c b/reactos/lib/sdk/crt/time_new/ctime64.c new file mode 100644 index 00000000000..7cba433d978 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/ctime64.c @@ -0,0 +1,9 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/ctime64.c + * PURPOSE: Implementation of _ctime64 + * PROGRAMERS: Timo Kreuzer + */ +#define _USE_EXPLITIT_64BIT_TIME +#include "ctime.c" diff --git a/reactos/lib/sdk/crt/time_new/difftime.c b/reactos/lib/sdk/crt/time_new/difftime.c new file mode 100644 index 00000000000..59f1d5a51dc --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/difftime.c @@ -0,0 +1,23 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/difftime.c + * PURPOSE: Implementation of difftime + * PROGRAMERS: Timo Kreuzer + */ +#include +#include "bitsfixup.h" + +/** + * \name difftime + * \brief Retrurns the difference between two time_t values in seconds. + * \param time1 Beginning time. + * \param time2 Ending time. + */ +double +difftime( + time_t time1, /**< Beginning time */ + time_t time2) /**< Ending time */ +{ + return (double)(time1 - time2); +} diff --git a/reactos/lib/sdk/crt/time_new/difftime32.c b/reactos/lib/sdk/crt/time_new/difftime32.c new file mode 100644 index 00000000000..5dff9d54d6a --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/difftime32.c @@ -0,0 +1,9 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/difftime32.c + * PURPOSE: Implementation of _difftime32 + * PROGRAMERS: Timo Kreuzer + */ +#define _USE_EXPLITIT_32BIT_TIME +#include "difftime.c" diff --git a/reactos/lib/sdk/crt/time_new/difftime64.c b/reactos/lib/sdk/crt/time_new/difftime64.c new file mode 100644 index 00000000000..37820c9fc38 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/difftime64.c @@ -0,0 +1,9 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/difftime64.c + * PURPOSE: Implementation of _difftime64 + * PROGRAMERS: Timo Kreuzer + */ +#define _USE_EXPLITIT_64BIT_TIME +#include "difftime.c" diff --git a/reactos/lib/sdk/crt/time_new/ftime.c b/reactos/lib/sdk/crt/time_new/ftime.c new file mode 100644 index 00000000000..5e630450b4a --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/ftime.c @@ -0,0 +1,61 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/ftime.c + * PURPOSE: Deprecated BSD library call + * PROGRAMERS: Timo Kreuzer + */ +#include +#include +#include +#include "bitsfixup.h" + +/****************************************************************************** + * \name _ftime_s + * \brief Get the current time. + * \param [out] ptimeb Pointer to a structure of type struct _timeb that + * recieves the current time. + * \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx + */ +errno_t +_ftime_s(struct _timeb *ptimeb) +{ + DWORD ret; + TIME_ZONE_INFORMATION TimeZoneInformation; + FILETIME SystemTime; + + /* Validate parameters */ + if (!ptimeb) + { + _invalid_parameter(0, + 0,//__FUNCTION__, + _CRT_WIDE(__FILE__), + __LINE__, + 0); + return EINVAL; + } + + ret = GetTimeZoneInformation(&TimeZoneInformation); + ptimeb->dstflag = (ret == TIME_ZONE_ID_DAYLIGHT) ? 1 : 0; + ptimeb->timezone = TimeZoneInformation.Bias; + + GetSystemTimeAsFileTime(&SystemTime); + ptimeb->time = FileTimeToUnixTime(&SystemTime, &ptimeb->millitm); + + return 0; +} + +/****************************************************************************** + * \name _ftime + * \brief Get the current time. + * \param [out] ptimeb Pointer to a structure of type struct _timeb that + * recieves the current time. + * \note This function is for compatability and simply calls the secure + * version _ftime_s(). + * \sa http://msdn.microsoft.com/en-us/library/z54t9z5f.aspx + */ +void +_ftime(struct _timeb *ptimeb) +{ + _ftime_s(ptimeb); +} diff --git a/reactos/lib/sdk/crt/time_new/ftime32.c b/reactos/lib/sdk/crt/time_new/ftime32.c new file mode 100644 index 00000000000..fc636e48227 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/ftime32.c @@ -0,0 +1,9 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/ftime32.c + * PURPOSE: Implementation of _ftime32 + * PROGRAMERS: Timo Kreuzer + */ +#define _USE_EXPLITIT_32BIT_TIME +#include "ftime.c" diff --git a/reactos/lib/sdk/crt/time_new/ftime64.c b/reactos/lib/sdk/crt/time_new/ftime64.c new file mode 100644 index 00000000000..824ee07ffe8 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/ftime64.c @@ -0,0 +1,9 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/ftime64.c + * PURPOSE: Implementation of _ftime64 + * PROGRAMERS: Timo Kreuzer + */ +#define _USE_EXPLITIT_64BIT_TIME +#include "ftime.c" diff --git a/reactos/lib/sdk/crt/time_new/futime.c b/reactos/lib/sdk/crt/time_new/futime.c new file mode 100644 index 00000000000..fe1ec3d1da1 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/futime.c @@ -0,0 +1,61 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/futime.c + * PURPOSE: Implementation of _futime + * PROGRAMERS: Timo Kreuzer + */ +#include +#include +#include +#include "bitsfixup.h" + +HANDLE fdtoh(int fd); + +/****************************************************************************** + * \name _futime + * \brief Set a files modification time. + * \param [out] ptimeb Pointer to a structure of type struct _timeb that + * recieves the current time. + * \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx + */ +int +_futime(int fd, struct _utimbuf *filetime) +{ + HANDLE handle; + FILETIME at, wt; + + handle = fdtoh(fd); + if (handle == INVALID_HANDLE_VALUE) + { + return -1; + } + + if (!filetime) + { + time_t currTime; + _time(&currTime); + RtlSecondsSince1970ToTime(currTime, (LARGE_INTEGER *)&at); + wt = at; + } + else + { + RtlSecondsSince1970ToTime(filetime->actime, (LARGE_INTEGER *)&at); + if (filetime->actime == filetime->modtime) + { + wt = at; + } + else + { + RtlSecondsSince1970ToTime(filetime->modtime, (LARGE_INTEGER *)&wt); + } + } + + if (!SetFileTime(handle, NULL, &at, &wt)) + { + __set_errno(GetLastError()); + return -1 ; + } + + return 0; +} diff --git a/reactos/lib/sdk/crt/time_new/futime32.c b/reactos/lib/sdk/crt/time_new/futime32.c new file mode 100644 index 00000000000..41b1321614c --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/futime32.c @@ -0,0 +1,9 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/futime32.c + * PURPOSE: Implementation of _futime32 + * PROGRAMERS: Timo Kreuzer + */ +#define _USE_EXPLITIT_32BIT_TIME +#include "futime.c" diff --git a/reactos/lib/sdk/crt/time_new/futime64.c b/reactos/lib/sdk/crt/time_new/futime64.c new file mode 100644 index 00000000000..d754b472c68 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/futime64.c @@ -0,0 +1,9 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/futime64.c + * PURPOSE: Implementation of _futime64 + * PROGRAMERS: Timo Kreuzer + */ +#define _USE_EXPLITIT_64BIT_TIME +#include "futime.c" diff --git a/reactos/lib/sdk/crt/time_new/gmtime.c b/reactos/lib/sdk/crt/time_new/gmtime.c new file mode 100644 index 00000000000..e48bcdcc930 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/gmtime.c @@ -0,0 +1,146 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/gmtime.c + * PURPOSE: Implementation of gmtime, _gmtime32, _gmtime64 + * PROGRAMERS: Timo Kreuzer + */ +#include + +unsigned int g_monthdays[13] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; +unsigned int g_lpmonthdays[13] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}; + +struct tm * +_gmtime_worker(struct tm *ptm, __time64_t time, int do_dst) +{ + unsigned int days, daystoyear, dayinyear, leapdays, leapyears, years, month; + unsigned int secondinday, secondinhour; + unsigned int *padays; + + if (time < 0) + { + return 0; + } + + /* Divide into date and time */ + days = time / SECONDSPERDAY; + secondinday = time % SECONDSPERDAY; + + /* Shift to days from 1.1.1601 */ + days += DIFFDAYS; + + /* Calculate leap days passed till today */ + leapdays = leapdays_passed(days); + + /* Calculate number of full leap years passed */ + leapyears = leapyears_passed(days); + + /* Are more leap days passed than leap years? */ + if (leapdays > leapyears) + { + /* Yes, we're in a leap year */ + padays = g_lpmonthdays; + } + else + { + /* No, normal year */ + padays = g_monthdays; + } + + /* Calculate year */ + years = (days - leapdays) / 365; + ptm->tm_year = years - 299; + + /* Calculate number of days till 1.1. of this year */ + daystoyear = years * 365 + leapyears; + + /* Calculate the day in this year */ + dayinyear = days - daystoyear; + + /* Shall we do DST corrections? */ + ptm->tm_isdst = 0; + if (do_dst) + { + unsigned int yeartime = dayinyear * SECONDSPERDAY + secondinday ; + if (yeartime >= dst_begin && yeartime <= dst_end) // FIXME! DST in winter + { + time -= _dstbias; + days = time / SECONDSPERDAY + DIFFDAYS; + dayinyear = days - daystoyear; + ptm->tm_isdst = 1; + } + } + + ptm->tm_yday = dayinyear; + + /* dayinyear < 366 => terminates with i <= 11 */ + for (month = 0; dayinyear >= padays[month+1]; month++) + ; + + /* Set month and day in month */ + ptm->tm_mon = month; + ptm->tm_mday = 1 + dayinyear - padays[month]; + + /* Get weekday */ + ptm->tm_wday = (days + 4) % 7; + + /* Calculate hour and second in hour */ + ptm->tm_hour = secondinday / SECONDSPERHOUR; + secondinhour = secondinday % SECONDSPERHOUR; + + /* Calculate minute and second */ + ptm->tm_min = secondinhour / 60; + ptm->tm_sec = secondinhour % 60; + + return ptm; +} + +/****************************************************************************** + * \name _gmtime64 + * \brief + * \param ptime Pointer to a variable of type __time64_t containing the time. + */ +struct tm * +_gmtime64(const __time64_t * ptime) +{ + PTHREADDATA pThreadData; + struct tm *ptm; + __time64_t time = *ptime; + + /* Validate parameters */ + if (time < 0) + { + return 0; + } + + /* Get pointer to TLS tm buffer */ + pThreadData = GetThreadData(); + ptm = &pThreadData->tmbuf; + + /* Use _gmtime_worker to do the ral work */ + return _gmtime_worker(ptm, time, 0); +} + +/****************************************************************************** + * \name _gmtime32 + * \brief + * \param ptime Pointer to a variable of type __time32_t containing the time. + */ +struct tm * +_gmtime32(const __time32_t * ptime) +{ + __time64_t time64 = (__time64_t)*ptime; + return _gmtime64(&time64); +} + +/****************************************************************************** + * \name gmtime + * \brief + * \param ptime Pointer to a variable of type time_t containing the time. + */ +struct tm * +gmtime(const time_t * ptime) +{ + __time64_t time64 = (__time64_t)*ptime; + return _gmtime64(&time64); +} diff --git a/reactos/lib/sdk/crt/time_new/localtime.c b/reactos/lib/sdk/crt/time_new/localtime.c new file mode 100644 index 00000000000..c10337a63ec --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/localtime.c @@ -0,0 +1,65 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/localtime.c + * PURPOSE: Implementation of localtime, localtime_s + * PROGRAMERS: Timo Kreuzer + */ +#include +#include +#include "bitsfixup.h" + +errno_t +localtime_s(struct tm* _tm, const time_t *ptime) +{ + + /* Validate parameters */ + if (!_tm || !ptime) + { + _invalid_parameter(NULL, + 0,//__FUNCTION__, + _CRT_WIDE(__FILE__), + __LINE__, + 0); + return EINVAL; + } + + + return 0; +} + +extern char _tz_is_set; + +struct tm * +localtime(const time_t *ptime) +{ + time_t time = *ptime; + struct tm * ptm; + + /* Check for invalid time value */ + if (time < 0) + { + return 0; + } + + /* Never without */ + if (!_tz_is_set) + _tzset(); + + /* Check for overflow */ + + /* Correct for timezone */ + time -= _timezone; +#if 0 + /* Correct for daylight saving */ + if (_isdstime(time)) + { + ptm->tm_isdst = 1; + time -= _dstbias; + } +#endif + ptm = gmtime(&time); + + return ptm; +} + diff --git a/reactos/lib/sdk/crt/time_new/localtime32.c b/reactos/lib/sdk/crt/time_new/localtime32.c new file mode 100644 index 00000000000..9116270a7a3 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/localtime32.c @@ -0,0 +1,9 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/localtime32.c + * PURPOSE: Implementation of _localtime32 + * PROGRAMERS: Timo Kreuzer + */ +#define _USE_EXPLITIT_32BIT_TIME +#include "localtime.c" diff --git a/reactos/lib/sdk/crt/time_new/localtime64.c b/reactos/lib/sdk/crt/time_new/localtime64.c new file mode 100644 index 00000000000..c06d371be8b --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/localtime64.c @@ -0,0 +1,9 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/localtime64.c + * PURPOSE: Implementation of _localtime64 + * PROGRAMERS: Timo Kreuzer + */ +#define _USE_EXPLITIT_64BIT_TIME +#include "localtime.c" diff --git a/reactos/lib/sdk/crt/time_new/mktime.c b/reactos/lib/sdk/crt/time_new/mktime.c new file mode 100644 index 00000000000..0ad10175194 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/mktime.c @@ -0,0 +1,124 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/mktime.c + * PURPOSE: Implementation of mktime, _mkgmtime + * PROGRAMERS: Timo Kreuzer + */ +#include + +time_t +mktime_worker(struct tm * ptm, int utc) +{ + return 0; +} + +/* int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +*/ + +static int g_monthdays[13] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; + + +/** + * \name _mkgmtime + * + */ +time_t +_mkgmtime(struct tm *ptm) +{ + struct tm *ptm2; + time_t time; + int mons, years, leapyears; + + /* Normalize year and month */ + if (ptm->tm_mon < 0) + { + mons = -ptm->tm_mon - 1; + ptm->tm_year -= 1 + mons / 12; + ptm->tm_mon = 11 - (mons % 12); + } + else if (ptm->tm_mon > 11) + { + mons = ptm->tm_mon; + ptm->tm_year += (mons / 12); + ptm->tm_mon = mons % 12; + } + + /* Is it inside margins */ + if (ptm->tm_year < 70 || ptm->tm_year > 139) // FIXME: max year for 64 bits + { + return -1; + } + + years = ptm->tm_year - 70; + + /* Number of leapyears passed since 1970 */ + leapyears = (years + 1) / 4; + + /* Calculate days up to 1st of Jan */ + time = years * 365 + leapyears; + + /* Calculate days up to 1st of month */ + time += g_monthdays[ptm->tm_mon]; + + /* Check if we need to add a leap day */ + if (((years + 2) % 4) == 0) + { + if (ptm->tm_mon > 2) + { + time++; + } + } + + time += ptm->tm_mday - 1; + + time *= 24; + time += ptm->tm_hour; + + time *= 60; + time += ptm->tm_min; + + time *= 60; + time += ptm->tm_sec; + + if (time < 0) + { + return -1; + } + + /* Finally get normalized tm struct */ + ptm2 = gmtime(&time); + if (!ptm2) + { + return -1; + } + *ptm = *ptm2; + + return time; +} + +time_t +mktime(struct tm *ptm) +{ + time_t time; + + /* Convert the time as if it was UTC */ + time = _mkgmtime(ptm); + + /* Apply offset */ + if (time != -1) + { + time += _timezone; + } + + return time; +} + diff --git a/reactos/lib/sdk/crt/time_new/strdate.c b/reactos/lib/sdk/crt/time_new/strdate.c new file mode 100644 index 00000000000..0aaa023c8b5 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/strdate.c @@ -0,0 +1,23 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/msvcrt/time/strtime.c + * PURPOSE: Fills a buffer with a formatted date representation + * PROGRAMER: Ariadne + * UPDATE HISTORY: + * 28/12/98: Created + */ +#include + +/* + * @implemented + */ +char* _strdate(char* date) +{ + static const char format[] = "MM'/'dd'/'yy"; + + GetDateFormatA(LOCALE_NEUTRAL, 0, NULL, format, date, 9); + + return date; + +} diff --git a/reactos/lib/sdk/crt/time_new/strftime.c b/reactos/lib/sdk/crt/time_new/strftime.c new file mode 100644 index 00000000000..f1416d151bb --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/strftime.c @@ -0,0 +1,12 @@ +#include +#include + +size_t +_tcsftime(_TCHAR *strDest, + size_t maxsize, + const _TCHAR *format, + const struct tm *timeptr) +{ + return 0; +} + diff --git a/reactos/lib/sdk/crt/time_new/strtime.c b/reactos/lib/sdk/crt/time_new/strtime.c new file mode 100644 index 00000000000..d6e10687152 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/strtime.c @@ -0,0 +1,22 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/msvcrt/time/strtime.c + * PURPOSE: Fills a buffer with a formatted time representation + * PROGRAMER: Ariadne + * UPDATE HISTORY: + * 28/12/98: Created + */ +#include + +/* + * @implemented + */ +char* _strtime(char* time) +{ + static const char format[] = "HH':'mm':'ss"; + + GetTimeFormatA(LOCALE_NEUTRAL, 0, NULL, format, time, 9); + + return time; +} diff --git a/reactos/lib/sdk/crt/time_new/time.c b/reactos/lib/sdk/crt/time_new/time.c new file mode 100644 index 00000000000..fcd23826cc7 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/time.c @@ -0,0 +1,24 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/sdk/crt/time/time.c + * PURPOSE: Implementation of _time (_tim32, _tim64) + * PROGRAMER: Timo Kreuzer + */ +#include +#include +#include "bitsfixup.h" + +time_t _time(time_t* ptime) +{ + FILETIME SystemTime; + time_t time = 0; + + if (ptime) + { + GetSystemTimeAsFileTime(&SystemTime); + time = FileTimeToUnixTime(&SystemTime, NULL); + *ptime = time; + } + return time; +} diff --git a/reactos/lib/sdk/crt/time_new/time32.c b/reactos/lib/sdk/crt/time_new/time32.c new file mode 100644 index 00000000000..5b43771e6ff --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/time32.c @@ -0,0 +1,3 @@ + +#define _USE_EXPLITIT_32BIT_TIME +#include "time.c" diff --git a/reactos/lib/sdk/crt/time_new/time64.c b/reactos/lib/sdk/crt/time_new/time64.c new file mode 100644 index 00000000000..1811dfaae7a --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/time64.c @@ -0,0 +1,3 @@ + +#define _USE_EXPLITIT_64BIT_TIME +#include "time.c" diff --git a/reactos/lib/sdk/crt/time_new/timezone.c b/reactos/lib/sdk/crt/time_new/timezone.c new file mode 100644 index 00000000000..b52373dc973 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/timezone.c @@ -0,0 +1,216 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/timezone.c + * PURPOSE: Implementation of time zone functions + * PROGRAMERS: Timo Kreuzer + */ +#include "precomp.h" + +char _tz_is_set = 0; + +/* buffers must hold 64 characters! */ +static char tz_name[64] = "PST"; +static char tz_dst_name[64] = "PDT"; + +long dst_begin = 0; +long dst_end = 0; + +/****************************************************************************** + * \var _tzname + */ +char * _tzname[2] = { + tz_name, + tz_dst_name, +}; + +/****************************************************************************** + * \var _daylight + */ +int _daylight = 1; + +/****************************************************************************** + * \name __p__daylight + * \brief Returns a pointer to the _daylight variable; + */ +void * +__p__daylight(void) +{ + return &_daylight; +} + +/****************************************************************************** + * \var _timezone + * \brief + */ +long _timezone = 28800; + +/****************************************************************************** + * \name __p__timezone + * \brief Returns a pointer to the _timezone variable; + */ +long * +__p__timezone(void) +{ + return &_timezone; +} + +/****************************************************************************** + * \var _dstbias + * \brief + */ +long _dstbias = 0; + +/****************************************************************************** + * \name __p__dstbias + * \brief Returns a pointer to the _dstbias variable; + */ +long * +__p__dstbias(void) +{ + return &_dstbias; +} + +/****************************************************************************** + * \name __p__tzname + * \brief Returns a pointer to the _tzname buffer; + */ +char ** +__p__tzname(void) +{ + return _tzname; +} + +/****************************************************************************** + * \name _tzset + * \brief Initializes the variables _daylight, _timezone, and _tzname from the + * "TZ" environment variable if available or else by calling + * GetTimeZoneInformation. + * \sa http://msdn.microsoft.com/en-us/library/90s5c885.aspx + */ +void +_tzset(void) +{ + const char * str; + + if (_tz_is_set) + { + return; + } + + /* Try to read the timezone from environment */ + str = getenv("TZ"); + if (str && str[0] != 0) + { + long hour = 0, min = 0, sec = 0; + int len = strnlen(str, 16); + int sign = 1; + + dst_begin = 0; + + for (;;) + { + /* Copy timezone name */ + strncpy(tz_name, str, 3); + str += 3; + len -= 3; + + if (len < 1) break; + + if (*str == '+' || *str == '-') + { + sign = *str == '-' ? -1 : 1; + str++; + len--; + } + + if (len < 1) break; + + hour = atol(str); + + while (*str != 0 && *str != ':') str++; + if (*str == 0) break; + + min = atol(++str); + + while (*str != 0 && *str != ':') str++; + if (*str == 0) break; + + sec = atol(++str); + + while (*str != 0 && *str <= '9') str++; + if (*str == 0) break; + + /* Copy DST name */ + strncpy(tz_dst_name, str, 3); + + // FIXME: set dst_begin etc + + /* We are finished */ + break; + } + + _timezone = sign * (((hour * 60) + min) * 60 + sec); + + } + else + { + TIME_ZONE_INFORMATION tzi; + DWORD ret; + + ret = GetTimeZoneInformation(&tzi); + if (ret == TIME_ZONE_ID_INVALID) + { + return; + } + + ret = WideCharToMultiByte(CP_ACP, + 0, + tzi.StandardName, + -1, + tz_name, + sizeof(tz_name), + NULL, + NULL); + + ret = WideCharToMultiByte(CP_ACP, + 0, + tzi.DaylightName, + -1, + tz_dst_name, + sizeof(tz_dst_name), + NULL, + NULL); + + _timezone = tzi.Bias * 60; + + if (tzi.DaylightDate.wMonth) + { + struct tm _tm; + + _daylight = 1; + _dstbias = (tzi.DaylightBias - tzi.StandardBias) * 60; + _tm.tm_year = 70; + _tm.tm_mon = tzi.DaylightDate.wMonth - 1; + _tm.tm_mday = tzi.DaylightDate.wDay; + _tm.tm_hour = tzi.DaylightDate.wHour; + _tm.tm_min = tzi.DaylightDate.wMinute; + _tm.tm_sec = tzi.DaylightDate.wSecond; + dst_begin = _mkgmtime(&_tm); + _tm.tm_mon = tzi.StandardDate.wMonth - 1; + _tm.tm_mday = tzi.StandardDate.wDay; + _tm.tm_hour = tzi.StandardDate.wHour; + _tm.tm_min = tzi.StandardDate.wMinute; + _tm.tm_sec = tzi.StandardDate.wSecond; + dst_end = _mkgmtime(&_tm); + } + else + { + _daylight = 0; + _dstbias = 0; + } + + } + _tz_is_set = 1; +} + diff --git a/reactos/lib/sdk/crt/time_new/tzname.c b/reactos/lib/sdk/crt/time_new/tzname.c new file mode 100644 index 00000000000..927042e7800 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/tzname.c @@ -0,0 +1,9 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/ctime.c + * PURPOSE: Implementation of ctime + * PROGRAMERS: Timo Kreuzer + */ +#include + diff --git a/reactos/lib/sdk/crt/time_new/utime.c b/reactos/lib/sdk/crt/time_new/utime.c new file mode 100644 index 00000000000..58b00232ce9 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/utime.c @@ -0,0 +1,25 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/utime.c + * PURPOSE: Implementation of utime, _wutime + * PROGRAMERS: Timo Kreuzer + */ +#include +#include +#include +#include "bitsfixup.h" + +int +_tutime(const _TCHAR* path, struct _utimbuf *t) +{ + int fd = _topen(path, _O_WRONLY | _O_BINARY); + + if (fd > 0) + { + int retVal = _futime(fd, t); + _close(fd); + return retVal; + } + return -1; +} diff --git a/reactos/lib/sdk/crt/time_new/utime32.c b/reactos/lib/sdk/crt/time_new/utime32.c new file mode 100644 index 00000000000..5e8ebeb0c94 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/utime32.c @@ -0,0 +1,10 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/utime32.c + * PURPOSE: Implementation of _utime32 + * PROGRAMERS: Timo Kreuzer + */ + +#define _USE_EXPLITIT_32BIT_TIME +#include "utime.c" diff --git a/reactos/lib/sdk/crt/time_new/utime64.c b/reactos/lib/sdk/crt/time_new/utime64.c new file mode 100644 index 00000000000..caffd02f77a --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/utime64.c @@ -0,0 +1,9 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/utime64.c + * PURPOSE: Implementation of _utime64 + * PROGRAMERS: Timo Kreuzer + */ +#define _USE_EXPLITIT_64BIT_TIME +#include "utime.c" diff --git a/reactos/lib/sdk/crt/time_new/wasctime.c b/reactos/lib/sdk/crt/time_new/wasctime.c new file mode 100644 index 00000000000..9c275410b70 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/wasctime.c @@ -0,0 +1,11 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/wasctime.c + * PURPOSE: Implementation of _wasctime + * PROGRAMERS: Timo Kreuzer + */ +#define UNICODE +#define _UNICODE + +#include "asctime.c" diff --git a/reactos/lib/sdk/crt/time_new/wcsftime.c b/reactos/lib/sdk/crt/time_new/wcsftime.c new file mode 100644 index 00000000000..2936b93262a --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/wcsftime.c @@ -0,0 +1,11 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/wcsftime.c + * PURPOSE: Implementation of _wcsftime + * PROGRAMERS: Timo Kreuzer + */ +#define UNICODE +#define _UNICODE + +#include "strftime.c" diff --git a/reactos/lib/sdk/crt/time_new/wctime.c b/reactos/lib/sdk/crt/time_new/wctime.c new file mode 100644 index 00000000000..e3058b58a1f --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/wctime.c @@ -0,0 +1,11 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/wctime.c + * PURPOSE: Implementation of _wctime + * PROGRAMERS: Timo Kreuzer + */ +#define UNICODE +#define _UNICODE + +#include "ctime.c" diff --git a/reactos/lib/sdk/crt/time_new/wctime32.c b/reactos/lib/sdk/crt/time_new/wctime32.c new file mode 100644 index 00000000000..eba262cc588 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/wctime32.c @@ -0,0 +1,12 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/wctime32.c + * PURPOSE: Implementation of _wctime32 + * PROGRAMERS: Timo Kreuzer + */ +#define UNICODE +#define _UNICODE + +#define _USE_EXPLITIT_32BIT_TIME +#include "ctime.c" diff --git a/reactos/lib/sdk/crt/time_new/wctime64.c b/reactos/lib/sdk/crt/time_new/wctime64.c new file mode 100644 index 00000000000..43ed93d0755 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/wctime64.c @@ -0,0 +1,12 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/wctime64.c + * PURPOSE: Implementation of _Wctime64 + * PROGRAMERS: Timo Kreuzer + */ +#define UNICODE +#define _UNICODE + +#define _USE_EXPLITIT_64BIT_TIME +#include "ctime.c" diff --git a/reactos/lib/sdk/crt/time_new/wstrdate.c b/reactos/lib/sdk/crt/time_new/wstrdate.c new file mode 100644 index 00000000000..ac67c8a6eb0 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/wstrdate.c @@ -0,0 +1,23 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/msvcrt/time/strtime.c + * PURPOSE: Fills a buffer with a formatted date representation + * PROGRAMER: Ariadne + * UPDATE HISTORY: + * 28/12/98: Created + */ +#include + +/* + * @implemented + */ +wchar_t* _wstrdate(wchar_t* date) +{ + static const WCHAR format[] = { 'M','M','\'','/','\'','d','d','\'','/','\'','y','y',0 }; + + GetDateFormatW(LOCALE_NEUTRAL, 0, NULL, format, (LPWSTR)date, 9); + + return date; + +} diff --git a/reactos/lib/sdk/crt/time_new/wstrtime.c b/reactos/lib/sdk/crt/time_new/wstrtime.c new file mode 100644 index 00000000000..322c7ba824b --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/wstrtime.c @@ -0,0 +1,22 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/msvcrt/time/strtime.c + * PURPOSE: Fills a buffer with a formatted time representation + * PROGRAMER: Ariadne + * UPDATE HISTORY: + * 28/12/98: Created + */ +#include + +/* + * @implemented + */ +wchar_t* _wstrtime(wchar_t* time) +{ + static const WCHAR format[] = { 'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0 }; + + GetTimeFormatW(LOCALE_NEUTRAL, 0, NULL, format, (LPWSTR)time, 9); + + return time; +} diff --git a/reactos/lib/sdk/crt/time_new/wutime.c b/reactos/lib/sdk/crt/time_new/wutime.c new file mode 100644 index 00000000000..9a5d5d165de --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/wutime.c @@ -0,0 +1,11 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/wutime.c + * PURPOSE: Implementation of _wutime + * PROGRAMERS: Timo Kreuzer + */ +#define UNICODE +#define _UNICODE + +#include "utime.c" diff --git a/reactos/lib/sdk/crt/time_new/wutime32.c b/reactos/lib/sdk/crt/time_new/wutime32.c new file mode 100644 index 00000000000..b6bda2dafe5 --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/wutime32.c @@ -0,0 +1,12 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/wutime32.c + * PURPOSE: Implementation of _wutime32 + * PROGRAMERS: Timo Kreuzer + */ +#define UNICODE +#define _UNICODE + +#define _USE_EXPLITIT_32BIT_TIME +#include "utime.c" diff --git a/reactos/lib/sdk/crt/time_new/wutime64.c b/reactos/lib/sdk/crt/time_new/wutime64.c new file mode 100644 index 00000000000..fac19d41c5f --- /dev/null +++ b/reactos/lib/sdk/crt/time_new/wutime64.c @@ -0,0 +1,12 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT library + * FILE: lib/sdk/crt/time/wutime64.c + * PURPOSE: Implementation of _wutime64 + * PROGRAMERS: Timo Kreuzer + */ +#define UNICODE +#define _UNICODE + +#define _USE_EXPLITIT_64BIT_TIME +#include "utime.c"