Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys.

This commit is contained in:
Colin Finck 2017-10-03 07:45:34 +00:00
parent b94e2d8ca0
commit c2c66aff7d
24198 changed files with 0 additions and 37285 deletions

168
sdk/lib/crt/time/asctime.c Normal file
View file

@ -0,0 +1,168 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/asctime.c
* PURPOSE: Implementation of asctime(), _asctime_s()
* PROGRAMERS: Timo Kreuzer
*/
#include <precomp.h>
#include <tchar.h>
#include <time.h>
#include "bitsfixup.h"
#define DAYSPERWEEK 7
#define MONSPERYEAR 12
#define HUNDREDYEAROFFSET 19
static const _TCHAR wday_name[DAYSPERWEEK][5] =
{
_T("Sun "), _T("Mon "), _T("Tue "), _T("Wed "),
_T("Thu "), _T("Fri "), _T("Sat ")
};
static const _TCHAR mon_name[MONSPERYEAR][5] =
{
_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
#pragma pack(push,1)
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;
#pragma pack(pop)
FORCEINLINE
_TCHAR2
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;
}
static __inline
void
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_hour);
buf->Sep1 = ':';
buf->Minute = IntToChar2(ptm->tm_min);
buf->Sep2 = ':';
buf->Second = IntToChar2(ptm->tm_sec);
buf->Space2 = ' ';
buf->Year[0] = IntToChar2(ptm->tm_year / 100 + HUNDREDYEAROFFSET);
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)
{
#if 0
_invalid_parameter(NULL,
#ifdef UNICODE
L"_wasctime",
#else
L"asctime",
#endif
_CRT_WIDE(__FILE__),
__LINE__,
0);
#endif
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)
{
thread_data_t *data = msvcrt_get_thread_data();
_TCHAR *pstr;
#ifndef _UNICODE
pstr = data->asctime_buffer;
#else
pstr = data->wasctime_buffer;
#endif
if(!pstr)
pstr = malloc(sizeof(struct tm));
/* Fill the buffer */
FillBuf((timebuf_t*)pstr, ptm);
return pstr;
}

View file

@ -0,0 +1,59 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/bitsfixup.h
* PURPOSE: definitions for different time_t versions
* PROGRAMERS: Timo Kreuzer
*/
#if defined(_USE_EXPLICIT_32BIT_TIME) || defined(_USE_EXPLICIT_64BIT_TIME)
#undef _timeb
#undef _ftime
#undef _tctime
#undef _tctime_s
#undef _tutime
#else
#define _time time
#endif
#undef _ftime_s
#ifdef _USE_EXPLICIT_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_EXPLICIT_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

30
sdk/lib/crt/time/clock.c Normal file
View file

@ -0,0 +1,30 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/clock.c
* PURPOSE: Implementation of clock()
* PROGRAMER: Timo Kreuzer
*/
#include <precomp.h>
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 (clock_t)FileTimeToUnixTime((FILETIME*)&Time, NULL);
};

55
sdk/lib/crt/time/ctime.c Normal file
View file

@ -0,0 +1,55 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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 <errno.h>
#define RC_INVOKED 1 // to prevent inline functions
#include <tchar.h>
#include <time.h>
#include "bitsfixup.h"
/* Doesn't really exist, but we need it here */
_CRTIMP errno_t __cdecl localtime_s(struct tm *_Tm,const time_t *_Time);
/******************************************************************************
* \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);
}

View file

@ -0,0 +1,9 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_32BIT_TIME
#include "ctime.c"

View file

@ -0,0 +1,9 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_64BIT_TIME
#include "ctime.c"

View file

@ -0,0 +1,23 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/difftime.c
* PURPOSE: Implementation of difftime
* PROGRAMERS: Timo Kreuzer
*/
#include <time.h>
#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);
}

View file

@ -0,0 +1,9 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_32BIT_TIME
#include "difftime.c"

View file

@ -0,0 +1,9 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_64BIT_TIME
#include "difftime.c"

58
sdk/lib/crt/time/ftime.c Normal file
View file

@ -0,0 +1,58 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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 <precomp.h>
#include <sys/timeb.h>
#include "bitsfixup.h"
/******************************************************************************
* \name _ftime_s
* \brief Get the current time.
* \param [out] ptimeb Pointer to a structure of type struct _timeb that
* receives the current time.
* \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx
*/
errno_t
CDECL
_ftime_s(struct _timeb *ptimeb)
{
DWORD ret;
TIME_ZONE_INFORMATION TimeZoneInformation;
FILETIME SystemTime;
/* Validate parameters */
if (!MSVCRT_CHECK_PMT( ptimeb != NULL ))
{
*_errno() = EINVAL;
return EINVAL;
}
ret = GetTimeZoneInformation(&TimeZoneInformation);
ptimeb->dstflag = (ret == TIME_ZONE_ID_DAYLIGHT) ? 1 : 0;
ptimeb->timezone = (short)TimeZoneInformation.Bias;
GetSystemTimeAsFileTime(&SystemTime);
ptimeb->time = (time_t)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
* receives 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
CDECL
_ftime(struct _timeb *ptimeb)
{
_ftime_s(ptimeb);
}

View file

@ -0,0 +1,9 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_32BIT_TIME
#include "ftime.c"

View file

@ -0,0 +1,9 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_64BIT_TIME
#include "ftime.c"

94
sdk/lib/crt/time/futime.c Normal file
View file

@ -0,0 +1,94 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/futime.c
* PURPOSE: Implementation of _futime
* PROGRAMERS: Wine team
*/
/*
* msvcrt.dll file functions
*
* Copyright 1996,1998 Marcus Meissner
* Copyright 1996 Jukka Iivonen
* Copyright 1997,2000 Uwe Bonnes
* Copyright 2000 Jon Griffiths
* Copyright 2004 Eric Pouech
* Copyright 2004 Juan Lang
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* TODO
* Use the file flag hints O_SEQUENTIAL, O_RANDOM, O_SHORT_LIVED
*/
#include <precomp.h>
#define RC_INVOKED 1 // to prevent inline functions
#include <time.h>
#include <sys/utime.h>
#include "bitsfixup.h"
HANDLE fdtoh(int fd);
/******************************************************************************
* \name _futime
* \brief Set a file's modification time.
* \param [out] ptimeb Pointer to a structure of type struct _timeb that
* receives 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((ULONG)currTime,
(LARGE_INTEGER *)&at);
wt = at;
}
else
{
RtlSecondsSince1970ToTime((ULONG)filetime->actime,
(LARGE_INTEGER *)&at);
if (filetime->actime == filetime->modtime)
{
wt = at;
}
else
{
RtlSecondsSince1970ToTime((ULONG)filetime->modtime,
(LARGE_INTEGER *)&wt);
}
}
if (!SetFileTime(handle, NULL, &at, &wt))
{
_dosmaperr(GetLastError());
return -1 ;
}
return 0;
}

View file

@ -0,0 +1,9 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_32BIT_TIME
#include "futime.c"

View file

@ -0,0 +1,9 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_64BIT_TIME
#include "futime.c"

200
sdk/lib/crt/time/gmtime.c Normal file
View file

@ -0,0 +1,200 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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 <precomp.h>
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 = (unsigned int)(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)
{
int yeartime = dayinyear * SECONDSPERDAY + secondinday ;
if (yeartime >= dst_begin && yeartime <= dst_end) // FIXME! DST in winter
{
time -= _dstbias;
days = (unsigned int)(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 + 1) % 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)
{
thread_data_t *data = msvcrt_get_thread_data();
/* Validate parameters */
if (!ptime || *ptime < 0)
{
return NULL;
}
if(!data->time_buffer)
data->time_buffer = malloc(sizeof(struct tm));
/* Use _gmtime_worker to do the real work */
return _gmtime_worker(data->time_buffer, *ptime, 0);
}
errno_t
_gmtime64_s(
struct tm* ptm,
const __time64_t* ptime)
{
__time64_t time;
if (!ptm)
{
MSVCRT_INVALID_PMT("ptm == NULL", ERROR_BAD_COMMAND);
return ERROR_BAD_COMMAND;
}
if (!ptime)
{
MSVCRT_INVALID_PMT("ptime == NULL", ERROR_BAD_COMMAND);
return ERROR_BAD_COMMAND;
}
time = *ptime;
_gmtime_worker(ptm, time, 0);
return ERROR_SUCCESS;
}
/******************************************************************************
* \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;
if (!ptime)
return NULL;
time64 = *ptime;
return _gmtime64(&time64);
}
errno_t
_gmtime32_s(
struct tm* ptm,
const __time32_t* ptime)
{
__time64_t time = *ptime;
if (!ptm)
{
MSVCRT_INVALID_PMT("ptm == NULL", ERROR_BAD_COMMAND);
return ERROR_BAD_COMMAND;
}
if (!ptime)
{
MSVCRT_INVALID_PMT("ptime == NULL", ERROR_BAD_COMMAND);
return ERROR_BAD_COMMAND;
}
_gmtime_worker(ptm, time, 0);
return ERROR_SUCCESS;
}
/******************************************************************************
* \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;
if (!ptime)
return NULL;
time64 = *ptime;
return _gmtime64(&time64);
}

View file

@ -0,0 +1,80 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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
* Samuel Serapión
*/
#include <precomp.h>
#include <time.h>
#include "bitsfixup.h"
//fix me: header?
#define _MAX__TIME64_T 0x793406fffLL /* number of seconds from
00:00:00, 01/01/1970 UTC to
23:59:59. 12/31/3000 UTC */
errno_t
localtime_s(struct tm* _tm, const time_t *ptime)
{
/* check for NULL */
if (!_tm || !ptime )
{
if(_tm) memset(_tm, 0xFF, sizeof(struct tm));
_invalid_parameter(NULL,
0,//__FUNCTION__,
_CRT_WIDE(__FILE__),
__LINE__,
0);
_set_errno(EINVAL);
return EINVAL;
}
/* Validate input */
if (*ptime < 0 || *ptime > _MAX__TIME64_T)
{
memset(_tm, 0xFF, sizeof(struct tm));
_set_errno(EINVAL);
return EINVAL;
}
_tm = localtime(ptime);
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;
}

View file

@ -0,0 +1,9 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_32BIT_TIME
#include "localtime.c"

View file

@ -0,0 +1,9 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_64BIT_TIME
#include "localtime.c"

151
sdk/lib/crt/time/mktime.c Normal file
View file

@ -0,0 +1,151 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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 <precomp.h>
#include "bitsfixup.h"
#define MAX_32BIT_TIME 0xFFFFFFFFULL
static int g_monthdays[13] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
__time64_t
mktime_worker(struct tm * ptm, int utc)
{
struct tm *ptm2;
__time64_t time;
int mons, years, leapyears;
TIME_ZONE_INFORMATION tzi;
DWORD ret;
/* 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 = _gmtime64(&time);
if (!ptm2)
{
return -1;
}
*ptm = *ptm2;
/* Finally adjust by the difference to GMT in seconds */
ret = GetTimeZoneInformation(&tzi);
if (ret != TIME_ZONE_ID_INVALID)
{
time += tzi.Bias * 60;
}
return time;
}
/* 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;
*/
/**
* \name _mkgmtime
*
*/
time_t
_mkgmtime(struct tm *ptm)
{
__time64_t time = mktime_worker(ptm, 1);
return (time_t)((time > MAX_32BIT_TIME) ? -1 : time);
}
time_t
mktime(struct tm *ptm)
{
__time64_t time = mktime_worker(ptm, 0);
return (time_t)((time > MAX_32BIT_TIME) ? -1 : time);
}
__time32_t
_mkgmtime32(struct tm *ptm)
{
__time64_t time = mktime_worker(ptm, 1);
return (__time32_t)((time > MAX_32BIT_TIME) ? -1 : time);
}
__time32_t
_mktime32(struct tm *ptm)
{
__time64_t time = mktime_worker(ptm, 0);
return (__time32_t)((time > MAX_32BIT_TIME) ? -1 : time);
}
__time64_t
_mkgmtime64(struct tm *ptm)
{
return mktime_worker(ptm, 1);
}
__time64_t
_mktime64(struct tm *ptm)
{
return mktime_worker(ptm, 0);
}

View file

@ -0,0 +1,45 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/strdate.c
* PURPOSE: Fills a buffer with a formatted date representation
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
/*
* @implemented
*/
char* _strdate(char* date)
{
static const char format[] = "MM'/'dd'/'yy";
GetDateFormatA(LOCALE_NEUTRAL, 0, NULL, format, date, 9);
return date;
}
/*
* @implemented
*/
int CDECL _strdate_s(char* date, size_t size)
{
if(date && size)
date[0] = '\0';
if(!date) {
*_errno() = EINVAL;
return EINVAL;
}
if(size < 9) {
*_errno() = ERANGE;
return ERANGE;
}
_strdate(date);
return 0;
}

325
sdk/lib/crt/time/strftime.c Normal file
View file

@ -0,0 +1,325 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/strftime.c
* PURPOSE:
* PROGRAMER:
*/
#include <precomp.h>
static inline BOOL strftime_date(char *str, size_t *pos, size_t max,
BOOL alternate, const struct tm *mstm, MSVCRT___lc_time_data *time_data)
{
char *format;
SYSTEMTIME st;
size_t ret;
st.wYear = mstm->tm_year + 1900;
st.wMonth = mstm->tm_mon + 1;
st.wDayOfWeek = mstm->tm_wday;
st.wDay = mstm->tm_mday;
st.wHour = mstm->tm_hour;
st.wMinute = mstm->tm_min;
st.wSecond = mstm->tm_sec;
st.wMilliseconds = 0;
format = alternate ? time_data->str.names.date : time_data->str.names.short_date;
ret = GetDateFormatA(time_data->lcid, 0, &st, format, NULL, 0);
if(ret && ret<max-*pos)
ret = GetDateFormatA(time_data->lcid, 0, &st, format, str+*pos, max-*pos);
if(!ret) {
*str = 0;
*_errno() = EINVAL;
return FALSE;
}else if(ret > max-*pos) {
*str = 0;
*_errno() = ERANGE;
return FALSE;
}
*pos += ret-1;
return TRUE;
}
static inline BOOL strftime_time(char *str, size_t *pos, size_t max,
const struct tm *mstm, MSVCRT___lc_time_data *time_data)
{
SYSTEMTIME st;
size_t ret;
st.wYear = mstm->tm_year + 1900;
st.wMonth = mstm->tm_mon + 1;
st.wDayOfWeek = mstm->tm_wday;
st.wDay = mstm->tm_mday;
st.wHour = mstm->tm_hour;
st.wMinute = mstm->tm_min;
st.wSecond = mstm->tm_sec;
st.wMilliseconds = 0;
ret = GetTimeFormatA(time_data->lcid, 0, &st, time_data->str.names.time, NULL, 0);
if(ret && ret<max-*pos)
ret = GetTimeFormatA(time_data->lcid, 0, &st, time_data->str.names.time,
str+*pos, max-*pos);
if(!ret) {
*str = 0;
*_errno() = EINVAL;
return FALSE;
}else if(ret > max-*pos) {
*str = 0;
*_errno() = ERANGE;
return FALSE;
}
*pos += ret-1;
return TRUE;
}
static inline BOOL strftime_str(char *str, size_t *pos, size_t max, char *src)
{
size_t len = strlen(src);
if(len > max-*pos) {
*str = 0;
*_errno() = ERANGE;
return FALSE;
}
memcpy(str+*pos, src, len);
*pos += len;
return TRUE;
}
static inline BOOL strftime_int(char *str, size_t *pos, size_t max,
int src, int prec, int l, int h)
{
size_t len;
if(src<l || src>h) {
*str = 0;
*_errno() = EINVAL;
return FALSE;
}
len = _snprintf(str+*pos, max-*pos, "%0*d", prec, src);
if(len == -1) {
*str = 0;
*_errno() = ERANGE;
return FALSE;
}
*pos += len;
return TRUE;
}
/*********************************************************************
* _Strftime (MSVCRT.@)
*/
size_t CDECL _Strftime(char *str, size_t max, const char *format,
const struct tm *mstm, MSVCRT___lc_time_data *time_data)
{
size_t ret, tmp;
BOOL alternate;
TRACE("(%p %ld %s %p %p)\n", str, max, format, mstm, time_data);
if(!str || !format) {
if(str && max)
*str = 0;
*_errno() = EINVAL;
return 0;
}
if(!time_data)
time_data = get_locinfo()->lc_time_curr;
for(ret=0; *format && ret<max; format++) {
if(*format != '%') {
str[ret++] = *format;
continue;
}
format++;
if(*format == '#') {
alternate = TRUE;
format++;
}else {
alternate = FALSE;
}
if(!mstm)
goto einval_error;
switch(*format) {
case 'c':
if(!strftime_date(str, &ret, max, alternate, mstm, time_data))
return 0;
if(ret < max)
str[ret++] = ' ';
if(!strftime_time(str, &ret, max, mstm, time_data))
return 0;
break;
case 'x':
if(!strftime_date(str, &ret, max, alternate, mstm, time_data))
return 0;
break;
case 'X':
if(!strftime_time(str, &ret, max, mstm, time_data))
return 0;
break;
case 'a':
if(mstm->tm_wday<0 || mstm->tm_wday>6)
goto einval_error;
if(!strftime_str(str, &ret, max, time_data->str.names.short_wday[mstm->tm_wday]))
return 0;
break;
case 'A':
if(mstm->tm_wday<0 || mstm->tm_wday>6)
goto einval_error;
if(!strftime_str(str, &ret, max, time_data->str.names.wday[mstm->tm_wday]))
return 0;
break;
case 'b':
if(mstm->tm_mon<0 || mstm->tm_mon>11)
goto einval_error;
if(!strftime_str(str, &ret, max, time_data->str.names.short_mon[mstm->tm_mon]))
return 0;
break;
case 'B':
if(mstm->tm_mon<0 || mstm->tm_mon>11)
goto einval_error;
if(!strftime_str(str, &ret, max, time_data->str.names.mon[mstm->tm_mon]))
return 0;
break;
case 'd':
if(!strftime_int(str, &ret, max, mstm->tm_mday, alternate ? 0 : 2, 0, 31))
return 0;
break;
case 'H':
if(!strftime_int(str, &ret, max, mstm->tm_hour, alternate ? 0 : 2, 0, 23))
return 0;
break;
case 'I':
tmp = mstm->tm_hour;
if(tmp > 12)
tmp -= 12;
else if(!tmp)
tmp = 12;
if(!strftime_int(str, &ret, max, tmp, alternate ? 0 : 2, 1, 12))
return 0;
break;
case 'j':
if(!strftime_int(str, &ret, max, mstm->tm_yday+1, alternate ? 0 : 3, 1, 366))
return 0;
break;
case 'm':
if(!strftime_int(str, &ret, max, mstm->tm_mon+1, alternate ? 0 : 2, 1, 12))
return 0;
break;
case 'M':
if(!strftime_int(str, &ret, max, mstm->tm_min, alternate ? 0 : 2, 0, 59))
return 0;
break;
case 'p':
if(mstm->tm_hour<0 || mstm->tm_hour>23)
goto einval_error;
if(!strftime_str(str, &ret, max, mstm->tm_hour<12 ?
time_data->str.names.am : time_data->str.names.pm))
return 0;
break;
case 'S':
if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, 59))
return 0;
break;
case 'w':
if(!strftime_int(str, &ret, max, mstm->tm_wday, 0, 0, 6))
return 0;
break;
case 'y':
if(!strftime_int(str, &ret, max, mstm->tm_year%100, alternate ? 0 : 2, 0, 99))
return 0;
break;
case 'Y':
tmp = 1900+mstm->tm_year;
if(!strftime_int(str, &ret, max, tmp, alternate ? 0 : 4, 0, 9999))
return 0;
break;
case 'z':
case 'Z':
_tzset();
if(_get_tzname(&tmp, str+ret, max-ret, mstm->tm_isdst ? 1 : 0))
return 0;
ret += tmp;
break;
case 'U':
case 'W':
if(mstm->tm_wday<0 || mstm->tm_wday>6 || mstm->tm_yday<0 || mstm->tm_yday>365)
goto einval_error;
if(*format == 'U')
tmp = mstm->tm_wday;
else if(!mstm->tm_wday)
tmp = 6;
else
tmp = mstm->tm_wday-1;
tmp = mstm->tm_yday/7 + (tmp <= ((unsigned)mstm->tm_yday%7));
if(!strftime_int(str, &ret, max, tmp, alternate ? 0 : 2, 0, 53))
return 0;
break;
case '%':
str[ret++] = '%';
break;
default:
WARN("unknown format %c\n", *format);
goto einval_error;
}
}
if(ret == max) {
if(max)
*str = 0;
*_errno() = ERANGE;
return 0;
}
str[ret] = 0;
return ret;
einval_error:
*str = 0;
*_errno() = EINVAL;
return 0;
}
/*********************************************************************
* strftime (MSVCRT.@)
*/
size_t CDECL strftime( char *str, size_t max, const char *format,
const struct tm *mstm )
{
return _Strftime(str, max, format, mstm, NULL);
}
/*********************************************************************
* wcsftime (MSVCRT.@)
*/
size_t CDECL wcsftime( wchar_t *str, size_t max,
const wchar_t *format, const struct tm *mstm )
{
char *s, *fmt;
size_t len;
TRACE("%p %ld %s %p\n", str, max, debugstr_w(format), mstm );
len = WideCharToMultiByte( CP_ACP, 0, format, -1, NULL, 0, NULL, NULL );
if (!(fmt = malloc( len ))) return 0;
WideCharToMultiByte( CP_ACP, 0, format, -1, fmt, len, NULL, NULL );
if ((s = malloc( max*4 )))
{
if (!strftime( s, max*4, fmt, mstm )) s[0] = 0;
len = MultiByteToWideChar( CP_ACP, 0, s, -1, str, max );
if (len) len--;
free( s );
}
else len = 0;
free( fmt );
return len;
}

View file

@ -0,0 +1,41 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/time/strtime.c
* PURPOSE: Fills a buffer with a formatted time representation
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
/*
* @implemented
*/
char* _strtime(char* time)
{
static const char format[] = "HH':'mm':'ss";
GetTimeFormatA(LOCALE_NEUTRAL, 0, NULL, format, time, 9);
return time;
}
int CDECL _strtime_s(char* time, size_t size)
{
if(time && size)
time[0] = '\0';
if(!time) {
*_errno() = EINVAL;
return EINVAL;
}
if(size < 9) {
*_errno() = ERANGE;
return ERANGE;
}
_strtime(time);
return 0;
}

25
sdk/lib/crt/time/time.c Normal file
View file

@ -0,0 +1,25 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/sdk/crt/time/time.c
* PURPOSE: Implementation of _time (_time32, _time64)
* PROGRAMER: Timo Kreuzer
*/
#include <precomp.h>
#include <time.h>
#include "bitsfixup.h"
time_t _time(time_t* ptime)
{
FILETIME SystemTime;
time_t time = 0;
GetSystemTimeAsFileTime(&SystemTime);
time = (time_t)FileTimeToUnixTime(&SystemTime, NULL);
if (ptime)
{
*ptime = time;
}
return time;
}

10
sdk/lib/crt/time/time32.c Normal file
View file

@ -0,0 +1,10 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/time32.c
* PURPOSE:
* PROGRAMER:
*/
#define _USE_EXPLICIT_32BIT_TIME
#include "time.c"

10
sdk/lib/crt/time/time64.c Normal file
View file

@ -0,0 +1,10 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/time64.c
* PURPOSE:
* PROGRAMER:
*/
#define _USE_EXPLICIT_64BIT_TIME
#include "time.c"

251
sdk/lib/crt/time/timezone.c Normal file
View file

@ -0,0 +1,251 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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 = 0;
/******************************************************************************
* \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;
size_t 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 = (long)_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 = (long)_mkgmtime(&_tm);
}
else
{
_daylight = 0;
_dstbias = 0;
}
}
_tz_is_set = 1;
}
/*********************************************************************
* _get_tzname (MSVCRT.@)
*/
int CDECL _get_tzname(size_t *ret, char *buf, size_t bufsize, int index)
{
char *str_timezone;
switch (index)
{
case 0:
str_timezone = tz_name;
break;
case 1:
str_timezone = tz_dst_name;
break;
default:
*_errno() = EINVAL;
return EINVAL;
}
if (!ret || (!buf && (bufsize > 0)) || (buf && !bufsize))
{
*_errno() = EINVAL;
return EINVAL;
}
*ret = strlen(str_timezone) + 1;
if(!buf && !bufsize)
return 0;
strncpy(buf, str_timezone, bufsize);
return 0;
}

55
sdk/lib/crt/time/utime.c Normal file
View file

@ -0,0 +1,55 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/utime.c
* PURPOSE: Implementation of utime, _wutime
* PROGRAMERS: Wine team
*/
/*
* msvcrt.dll file functions
*
* Copyright 1996,1998 Marcus Meissner
* Copyright 1996 Jukka Iivonen
* Copyright 1997,2000 Uwe Bonnes
* Copyright 2000 Jon Griffiths
* Copyright 2004 Eric Pouech
* Copyright 2004 Juan Lang
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* TODO
* Use the file flag hints O_SEQUENTIAL, O_RANDOM, O_SHORT_LIVED
*/
#include <precomp.h>
#include <tchar.h>
#define RC_INVOKED 1 // to prevent inline functions
#include <sys/utime.h>
#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;
}

View file

@ -0,0 +1,10 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_32BIT_TIME
#include "utime.c"

View file

@ -0,0 +1,9 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_64BIT_TIME
#include "utime.c"

View file

@ -0,0 +1,11 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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"

View file

@ -0,0 +1,11 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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"

11
sdk/lib/crt/time/wctime.c Normal file
View file

@ -0,0 +1,11 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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"

View file

@ -0,0 +1,12 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_32BIT_TIME
#include "ctime.c"

View file

@ -0,0 +1,12 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_64BIT_TIME
#include "ctime.c"

View file

@ -0,0 +1,42 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/wstrdate.c
* PURPOSE: Fills a buffer with a formatted date representation
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
/*
* @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;
}
int CDECL _wstrdate_s(wchar_t* date, size_t size)
{
if(date && size)
date[0] = '\0';
if(!date) {
*_errno() = EINVAL;
return EINVAL;
}
if(size < 9) {
*_errno() = ERANGE;
return ERANGE;
}
_wstrdate(date);
return 0;
}

View file

@ -0,0 +1,22 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/wstrtime.c
* PURPOSE: Fills a buffer with a formatted time representation
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 28/12/98: Created
*/
#include <precomp.h>
/*
* @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;
}

11
sdk/lib/crt/time/wutime.c Normal file
View file

@ -0,0 +1,11 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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"

View file

@ -0,0 +1,12 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_32BIT_TIME
#include "utime.c"

View file

@ -0,0 +1,12 @@
/*
* COPYRIGHT: LGPL, See LGPL.txt 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_EXPLICIT_64BIT_TIME
#include "utime.c"