2001-01-11 00:59:25 +01:00
|
|
|
/*
|
|
|
|
* msvcrt.dll date/time functions
|
|
|
|
*
|
|
|
|
* Copyright 1996,1998 Marcus Meissner
|
|
|
|
* Copyright 1996 Jukka Iivonen
|
|
|
|
* Copyright 1997,2000 Uwe Bonnes
|
|
|
|
* Copyright 2000 Jon Griffiths
|
2004-03-19 02:16:59 +01:00
|
|
|
* Copyright 2004 Hans Leidekker
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2001-04-23 20:22:33 +02:00
|
|
|
|
2002-08-26 23:53:24 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2006-06-19 22:42:05 +02:00
|
|
|
#define _POSIX_PTHREAD_SEMANTICS /* switch to a 2 arg style asctime_r on Solaris */
|
2001-01-11 00:59:25 +01:00
|
|
|
#include <time.h>
|
2002-08-26 23:53:24 +02:00
|
|
|
#ifdef HAVE_SYS_TIMES_H
|
|
|
|
# include <sys/times.h>
|
|
|
|
#endif
|
2004-11-06 04:53:53 +01:00
|
|
|
#include <limits.h>
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2001-04-23 20:22:33 +02:00
|
|
|
#include "msvcrt.h"
|
2010-03-29 00:01:53 +02:00
|
|
|
#include "mtdll.h"
|
2004-03-11 01:43:47 +01:00
|
|
|
#include "winbase.h"
|
2006-07-10 11:54:10 +02:00
|
|
|
#include "winnls.h"
|
2002-01-22 01:57:16 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2004-03-19 02:16:59 +01:00
|
|
|
static const int MonthLengths[2][12] =
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2004-03-19 02:16:59 +01:00
|
|
|
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
|
|
|
|
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline int IsLeapYear(int Year)
|
|
|
|
{
|
|
|
|
return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2006-01-14 17:22:03 +01:00
|
|
|
static inline void msvcrt_tm_to_unix( struct tm *dest, const struct MSVCRT_tm *src )
|
|
|
|
{
|
|
|
|
memset( dest, 0, sizeof(*dest) );
|
|
|
|
dest->tm_sec = src->tm_sec;
|
|
|
|
dest->tm_min = src->tm_min;
|
|
|
|
dest->tm_hour = src->tm_hour;
|
|
|
|
dest->tm_mday = src->tm_mday;
|
|
|
|
dest->tm_mon = src->tm_mon;
|
|
|
|
dest->tm_year = src->tm_year;
|
|
|
|
dest->tm_wday = src->tm_wday;
|
|
|
|
dest->tm_yday = src->tm_yday;
|
|
|
|
dest->tm_isdst = src->tm_isdst;
|
|
|
|
}
|
|
|
|
|
2007-08-21 07:25:28 +02:00
|
|
|
static inline void unix_tm_to_msvcrt( struct MSVCRT_tm *dest, const struct tm *src )
|
|
|
|
{
|
|
|
|
memset( dest, 0, sizeof(*dest) );
|
|
|
|
dest->tm_sec = src->tm_sec;
|
|
|
|
dest->tm_min = src->tm_min;
|
|
|
|
dest->tm_hour = src->tm_hour;
|
|
|
|
dest->tm_mday = src->tm_mday;
|
|
|
|
dest->tm_mon = src->tm_mon;
|
|
|
|
dest->tm_year = src->tm_year;
|
|
|
|
dest->tm_wday = src->tm_wday;
|
|
|
|
dest->tm_yday = src->tm_yday;
|
|
|
|
dest->tm_isdst = src->tm_isdst;
|
|
|
|
}
|
|
|
|
|
2010-10-11 12:24:20 +02:00
|
|
|
static inline void write_invalid_msvcrt_tm( struct MSVCRT_tm *tm )
|
|
|
|
{
|
|
|
|
tm->tm_sec = -1;
|
|
|
|
tm->tm_min = -1;
|
|
|
|
tm->tm_hour = -1;
|
|
|
|
tm->tm_mday = -1;
|
|
|
|
tm->tm_mon = -1;
|
|
|
|
tm->tm_year = -1;
|
|
|
|
tm->tm_wday = -1;
|
|
|
|
tm->tm_yday = -1;
|
|
|
|
tm->tm_isdst = -1;
|
|
|
|
}
|
|
|
|
|
2004-03-19 02:16:59 +01:00
|
|
|
#define SECSPERDAY 86400
|
|
|
|
/* 1601 to 1970 is 369 years plus 89 leap days */
|
|
|
|
#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
|
|
|
|
#define TICKSPERSEC 10000000
|
|
|
|
#define TICKSPERMSEC 10000
|
|
|
|
#define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
|
|
|
|
|
2001-11-12 16:47:26 +01:00
|
|
|
/**********************************************************************
|
2009-05-23 11:06:29 +02:00
|
|
|
* _mktime64 (MSVCRT.@)
|
2001-11-12 16:47:26 +01:00
|
|
|
*/
|
2009-05-23 11:06:29 +02:00
|
|
|
MSVCRT___time64_t CDECL MSVCRT__mktime64(struct MSVCRT_tm *mstm)
|
2001-11-12 16:47:26 +01:00
|
|
|
{
|
2007-08-21 07:25:28 +02:00
|
|
|
time_t secs;
|
|
|
|
struct tm tm;
|
|
|
|
|
|
|
|
msvcrt_tm_to_unix( &tm, mstm );
|
|
|
|
secs = mktime( &tm );
|
|
|
|
unix_tm_to_msvcrt( mstm, &tm );
|
|
|
|
|
|
|
|
return secs < 0 ? -1 : secs;
|
2004-03-19 02:16:59 +01:00
|
|
|
}
|
|
|
|
|
2009-05-23 11:06:29 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* _mktime32 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
MSVCRT___time32_t CDECL MSVCRT__mktime32(struct MSVCRT_tm *mstm)
|
|
|
|
{
|
|
|
|
return MSVCRT__mktime64( mstm );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* mktime (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
#ifdef _WIN64
|
|
|
|
MSVCRT___time64_t CDECL MSVCRT_mktime(struct MSVCRT_tm *mstm)
|
|
|
|
{
|
|
|
|
return MSVCRT__mktime64( mstm );
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
MSVCRT___time32_t CDECL MSVCRT_mktime(struct MSVCRT_tm *mstm)
|
|
|
|
{
|
|
|
|
return MSVCRT__mktime32( mstm );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-27 08:42:13 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* _mkgmtime64 (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* time->tm_isdst value is ignored
|
|
|
|
*/
|
|
|
|
MSVCRT___time64_t CDECL MSVCRT__mkgmtime64(struct MSVCRT_tm *time)
|
|
|
|
{
|
|
|
|
SYSTEMTIME st;
|
|
|
|
FILETIME ft;
|
|
|
|
MSVCRT___time64_t ret;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
st.wMilliseconds = 0;
|
|
|
|
st.wSecond = time->tm_sec;
|
|
|
|
st.wMinute = time->tm_min;
|
|
|
|
st.wHour = time->tm_hour;
|
|
|
|
st.wDay = time->tm_mday;
|
|
|
|
st.wMonth = time->tm_mon+1;
|
|
|
|
st.wYear = time->tm_year+1900;
|
|
|
|
|
|
|
|
if(!SystemTimeToFileTime(&st, &ft))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
FileTimeToSystemTime(&ft, &st);
|
|
|
|
time->tm_wday = st.wDayOfWeek;
|
|
|
|
|
|
|
|
for(i=time->tm_yday=0; i<st.wMonth-1; i++)
|
|
|
|
time->tm_yday += MonthLengths[IsLeapYear(st.wYear)][i];
|
|
|
|
time->tm_yday += st.wDay-1;
|
|
|
|
|
|
|
|
ret = ((MSVCRT___time64_t)ft.dwHighDateTime<<32)+ft.dwLowDateTime;
|
|
|
|
ret = (ret-TICKS_1601_TO_1970)/TICKSPERSEC;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* _mkgmtime32 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
MSVCRT___time32_t CDECL MSVCRT__mkgmtime32(struct MSVCRT_tm *time)
|
|
|
|
{
|
|
|
|
return MSVCRT__mkgmtime64(time);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* _mkgmtime (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
#ifdef _WIN64
|
|
|
|
MSVCRT___time64_t CDECL MSVCRT__mkgmtime(struct MSVCRT_tm *time)
|
|
|
|
{
|
|
|
|
return MSVCRT__mkgmtime64(time);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
MSVCRT___time32_t CDECL MSVCRT__mkgmtime(struct MSVCRT_tm *time)
|
|
|
|
{
|
|
|
|
return MSVCRT__mkgmtime32(time);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-03-19 02:16:59 +01:00
|
|
|
/*********************************************************************
|
2009-05-23 11:06:29 +02:00
|
|
|
* _localtime64 (MSVCRT.@)
|
2004-03-19 02:16:59 +01:00
|
|
|
*/
|
2009-05-23 11:06:29 +02:00
|
|
|
struct MSVCRT_tm* CDECL MSVCRT__localtime64(const MSVCRT___time64_t* secs)
|
2004-03-19 02:16:59 +01:00
|
|
|
{
|
2010-03-29 00:01:53 +02:00
|
|
|
struct tm *tm;
|
2007-08-21 14:44:24 +02:00
|
|
|
thread_data_t *data;
|
2007-08-21 07:25:28 +02:00
|
|
|
time_t seconds = *secs;
|
2006-02-11 12:15:21 +01:00
|
|
|
|
2007-08-21 14:44:24 +02:00
|
|
|
if (seconds < 0) return NULL;
|
|
|
|
|
2010-03-29 00:01:53 +02:00
|
|
|
_mlock(_TIME_LOCK);
|
|
|
|
if (!(tm = localtime( &seconds))) {
|
|
|
|
_munlock(_TIME_LOCK);
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-08-21 14:44:24 +02:00
|
|
|
|
|
|
|
data = msvcrt_get_thread_data();
|
2010-03-29 00:01:53 +02:00
|
|
|
unix_tm_to_msvcrt( &data->time_buffer, tm );
|
|
|
|
_munlock(_TIME_LOCK);
|
2004-03-19 02:16:59 +01:00
|
|
|
|
2007-08-21 07:25:28 +02:00
|
|
|
return &data->time_buffer;
|
2004-03-19 02:16:59 +01:00
|
|
|
}
|
|
|
|
|
2010-10-11 12:24:20 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _localtime64_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL _localtime64_s(struct MSVCRT_tm *time, const MSVCRT___time64_t *secs)
|
|
|
|
{
|
|
|
|
struct tm *tm;
|
|
|
|
time_t seconds;
|
|
|
|
|
|
|
|
if (!time || !secs || *secs < 0 || *secs > _MAX__TIME64_T)
|
|
|
|
{
|
|
|
|
if (time)
|
|
|
|
write_invalid_msvcrt_tm(time);
|
|
|
|
|
|
|
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
seconds = *secs;
|
|
|
|
|
|
|
|
_mlock(_TIME_LOCK);
|
|
|
|
if (!(tm = localtime(&seconds)))
|
|
|
|
{
|
|
|
|
_munlock(_TIME_LOCK);
|
|
|
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
unix_tm_to_msvcrt(time, tm);
|
|
|
|
_munlock(_TIME_LOCK);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-12-21 20:54:26 +01:00
|
|
|
/*********************************************************************
|
2009-05-23 11:06:29 +02:00
|
|
|
* _localtime32 (MSVCRT.@)
|
2005-12-21 20:54:26 +01:00
|
|
|
*/
|
2009-05-23 11:06:29 +02:00
|
|
|
struct MSVCRT_tm* CDECL MSVCRT__localtime32(const MSVCRT___time32_t* secs)
|
|
|
|
{
|
|
|
|
MSVCRT___time64_t secs64 = *secs;
|
|
|
|
return MSVCRT__localtime64( &secs64 );
|
|
|
|
}
|
|
|
|
|
2010-10-11 12:25:05 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _localtime32_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL _localtime32_s(struct MSVCRT_tm *time, const MSVCRT___time32_t *secs)
|
|
|
|
{
|
|
|
|
MSVCRT___time64_t secs64;
|
|
|
|
|
|
|
|
if (!time || !secs || *secs < 0)
|
|
|
|
{
|
|
|
|
if (time)
|
|
|
|
write_invalid_msvcrt_tm(time);
|
|
|
|
|
|
|
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
secs64 = *secs;
|
|
|
|
return _localtime64_s(time, &secs64);
|
|
|
|
}
|
|
|
|
|
2009-05-23 11:06:29 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* localtime (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
#ifdef _WIN64
|
|
|
|
struct MSVCRT_tm* CDECL MSVCRT_localtime(const MSVCRT___time64_t* secs)
|
|
|
|
{
|
|
|
|
return MSVCRT__localtime64( secs );
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
struct MSVCRT_tm* CDECL MSVCRT_localtime(const MSVCRT___time32_t* secs)
|
|
|
|
{
|
|
|
|
return MSVCRT__localtime32( secs );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _gmtime64 (MSVCRT.@)
|
|
|
|
*/
|
2010-08-27 01:46:09 +02:00
|
|
|
int CDECL MSVCRT__gmtime64_s(struct MSVCRT_tm *res, const MSVCRT___time64_t *secs)
|
2004-03-19 02:16:59 +01:00
|
|
|
{
|
2010-08-27 01:46:09 +02:00
|
|
|
int i;
|
|
|
|
FILETIME ft;
|
|
|
|
SYSTEMTIME st;
|
|
|
|
ULONGLONG time;
|
|
|
|
|
2010-10-11 12:24:30 +02:00
|
|
|
if (!res || !secs || *secs < 0) {
|
|
|
|
if (res) {
|
|
|
|
write_invalid_msvcrt_tm(res);
|
2010-08-27 01:46:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
2004-03-19 02:16:59 +01:00
|
|
|
|
2010-08-27 01:46:09 +02:00
|
|
|
time = *secs * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
|
2004-03-19 02:16:59 +01:00
|
|
|
|
2010-08-27 01:46:09 +02:00
|
|
|
ft.dwHighDateTime = (UINT)(time >> 32);
|
|
|
|
ft.dwLowDateTime = (UINT)time;
|
2004-03-19 02:16:59 +01:00
|
|
|
|
2010-08-27 01:46:09 +02:00
|
|
|
FileTimeToSystemTime(&ft, &st);
|
2004-03-19 02:16:59 +01:00
|
|
|
|
2010-08-27 01:46:09 +02:00
|
|
|
res->tm_sec = st.wSecond;
|
|
|
|
res->tm_min = st.wMinute;
|
|
|
|
res->tm_hour = st.wHour;
|
|
|
|
res->tm_mday = st.wDay;
|
|
|
|
res->tm_year = st.wYear - 1900;
|
|
|
|
res->tm_mon = st.wMonth - 1;
|
|
|
|
res->tm_wday = st.wDayOfWeek;
|
|
|
|
for (i = res->tm_yday = 0; i < st.wMonth - 1; i++) {
|
|
|
|
res->tm_yday += MonthLengths[IsLeapYear(st.wYear)][i];
|
|
|
|
}
|
2004-03-19 02:16:59 +01:00
|
|
|
|
2010-08-27 01:46:09 +02:00
|
|
|
res->tm_yday += st.wDay - 1;
|
|
|
|
res->tm_isdst = 0;
|
2004-03-19 02:16:59 +01:00
|
|
|
|
2010-08-27 01:46:09 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2004-03-19 02:16:59 +01:00
|
|
|
|
2010-08-27 01:46:09 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _gmtime64 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
struct MSVCRT_tm* CDECL MSVCRT__gmtime64(const MSVCRT___time64_t *secs)
|
|
|
|
{
|
|
|
|
thread_data_t * const data = msvcrt_get_thread_data();
|
|
|
|
|
|
|
|
if(MSVCRT__gmtime64_s(&data->time_buffer, secs))
|
|
|
|
return NULL;
|
|
|
|
return &data->time_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _gmtime32_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__gmtime32_s(struct MSVCRT_tm *res, const MSVCRT___time32_t *secs)
|
|
|
|
{
|
|
|
|
MSVCRT___time64_t secs64;
|
|
|
|
|
|
|
|
if(secs) {
|
|
|
|
secs64 = *secs;
|
|
|
|
return MSVCRT__gmtime64_s(res, &secs64);
|
|
|
|
}
|
|
|
|
return MSVCRT__gmtime64_s(res, NULL);
|
2001-11-12 16:47:26 +01:00
|
|
|
}
|
|
|
|
|
2009-05-23 11:06:29 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _gmtime32 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
struct MSVCRT_tm* CDECL MSVCRT__gmtime32(const MSVCRT___time32_t* secs)
|
|
|
|
{
|
2010-08-27 01:46:09 +02:00
|
|
|
MSVCRT___time64_t secs64;
|
|
|
|
|
|
|
|
if(!secs)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
secs64 = *secs;
|
2009-05-23 11:06:29 +02:00
|
|
|
return MSVCRT__gmtime64( &secs64 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* gmtime (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
#ifdef _WIN64
|
|
|
|
struct MSVCRT_tm* CDECL MSVCRT_gmtime(const MSVCRT___time64_t* secs)
|
|
|
|
{
|
|
|
|
return MSVCRT__gmtime64( secs );
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
struct MSVCRT_tm* CDECL MSVCRT_gmtime(const MSVCRT___time32_t* secs)
|
|
|
|
{
|
|
|
|
return MSVCRT__gmtime32( secs );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* _strdate (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
char* CDECL _strdate(char* date)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2007-08-21 07:25:28 +02:00
|
|
|
static const char format[] = "MM'/'dd'/'yy";
|
2004-03-19 02:16:59 +01:00
|
|
|
|
|
|
|
GetDateFormatA(LOCALE_NEUTRAL, 0, NULL, format, date, 9);
|
|
|
|
|
|
|
|
return date;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2010-08-27 01:46:00 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* _strdate_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL _strdate_s(char* date, MSVCRT_size_t size)
|
|
|
|
{
|
|
|
|
if(date && size)
|
|
|
|
date[0] = '\0';
|
|
|
|
|
|
|
|
if(!date) {
|
|
|
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(size < 9) {
|
|
|
|
*MSVCRT__errno() = MSVCRT_ERANGE;
|
|
|
|
return MSVCRT_ERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
_strdate(date);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-10-30 20:03:58 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* _wstrdate (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_wchar_t* CDECL _wstrdate(MSVCRT_wchar_t* date)
|
2005-10-30 20:03:58 +01:00
|
|
|
{
|
|
|
|
static const WCHAR format[] = { 'M','M','\'','/','\'','d','d','\'','/','\'','y','y',0 };
|
|
|
|
|
2009-01-29 11:15:54 +01:00
|
|
|
GetDateFormatW(LOCALE_NEUTRAL, 0, NULL, format, date, 9);
|
2005-10-30 20:03:58 +01:00
|
|
|
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
2010-08-27 01:46:00 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* _wstrdate_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL _wstrdate_s(MSVCRT_wchar_t* date, MSVCRT_size_t size)
|
|
|
|
{
|
|
|
|
if(date && size)
|
|
|
|
date[0] = '\0';
|
|
|
|
|
|
|
|
if(!date) {
|
|
|
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(size < 9) {
|
|
|
|
*MSVCRT__errno() = MSVCRT_ERANGE;
|
|
|
|
return MSVCRT_ERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
_wstrdate(date);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _strtime (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
char* CDECL _strtime(char* time)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2007-08-21 07:25:28 +02:00
|
|
|
static const char format[] = "HH':'mm':'ss";
|
2004-03-19 02:16:59 +01:00
|
|
|
|
2005-10-30 20:03:58 +01:00
|
|
|
GetTimeFormatA(LOCALE_NEUTRAL, 0, NULL, format, time, 9);
|
2004-03-19 02:16:59 +01:00
|
|
|
|
2005-10-30 20:03:58 +01:00
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
2010-08-27 01:45:31 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _strtime_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL _strtime_s(char* time, MSVCRT_size_t size)
|
|
|
|
{
|
|
|
|
if(time && size)
|
|
|
|
time[0] = '\0';
|
|
|
|
|
|
|
|
if(!time) {
|
|
|
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(size < 9) {
|
|
|
|
*MSVCRT__errno() = MSVCRT_ERANGE;
|
|
|
|
return MSVCRT_ERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
_strtime(time);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-10-30 20:03:58 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wstrtime (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_wchar_t* CDECL _wstrtime(MSVCRT_wchar_t* time)
|
2005-10-30 20:03:58 +01:00
|
|
|
{
|
|
|
|
static const WCHAR format[] = { 'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0 };
|
|
|
|
|
2009-01-29 11:15:54 +01:00
|
|
|
GetTimeFormatW(LOCALE_NEUTRAL, 0, NULL, format, time, 9);
|
2005-10-30 20:03:58 +01:00
|
|
|
|
|
|
|
return time;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2010-08-27 01:45:31 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _wstrtime_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL _wstrtime_s(MSVCRT_wchar_t* time, MSVCRT_size_t size)
|
|
|
|
{
|
|
|
|
if(time && size)
|
|
|
|
time[0] = '\0';
|
|
|
|
|
|
|
|
if(!time) {
|
|
|
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(size < 9) {
|
|
|
|
*MSVCRT__errno() = MSVCRT_ERANGE;
|
|
|
|
return MSVCRT_ERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
_wstrtime(time);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* clock (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_clock_t CDECL MSVCRT_clock(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2004-03-19 02:16:59 +01:00
|
|
|
FILETIME ftc, fte, ftk, ftu;
|
|
|
|
ULONGLONG utime, ktime;
|
|
|
|
|
|
|
|
MSVCRT_clock_t clock;
|
|
|
|
|
|
|
|
GetProcessTimes(GetCurrentProcess(), &ftc, &fte, &ftk, &ftu);
|
|
|
|
|
|
|
|
ktime = ((ULONGLONG)ftk.dwHighDateTime << 32) | ftk.dwLowDateTime;
|
|
|
|
utime = ((ULONGLONG)ftu.dwHighDateTime << 32) | ftu.dwLowDateTime;
|
|
|
|
|
2004-09-08 21:05:28 +02:00
|
|
|
clock = (utime + ktime) / (TICKSPERSEC / MSVCRT_CLOCKS_PER_SEC);
|
2004-03-19 02:16:59 +01:00
|
|
|
|
|
|
|
return clock;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2009-05-23 11:06:29 +02:00
|
|
|
* _difftime64 (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2009-05-23 11:06:29 +02:00
|
|
|
double CDECL MSVCRT__difftime64(MSVCRT___time64_t time1, MSVCRT___time64_t time2)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2004-03-19 02:16:59 +01:00
|
|
|
return (double)(time1 - time2);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2009-05-23 11:06:29 +02:00
|
|
|
* _difftime32 (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2009-05-23 11:06:29 +02:00
|
|
|
double CDECL MSVCRT__difftime32(MSVCRT___time32_t time1, MSVCRT___time32_t time2)
|
|
|
|
{
|
|
|
|
return (double)(time1 - time2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* difftime (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
#ifdef _WIN64
|
|
|
|
double CDECL MSVCRT_difftime(MSVCRT___time64_t time1, MSVCRT___time64_t time2)
|
|
|
|
{
|
|
|
|
return MSVCRT__difftime64( time1, time2 );
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
double CDECL MSVCRT_difftime(MSVCRT___time32_t time1, MSVCRT___time32_t time2)
|
|
|
|
{
|
|
|
|
return MSVCRT__difftime32( time1, time2 );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _ftime64 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void CDECL MSVCRT__ftime64(struct MSVCRT___timeb64 *buf)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2004-03-11 01:43:47 +01:00
|
|
|
TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
FILETIME ft;
|
|
|
|
ULONGLONG time;
|
|
|
|
|
|
|
|
DWORD tzid = GetTimeZoneInformation(&tzinfo);
|
|
|
|
GetSystemTimeAsFileTime(&ft);
|
|
|
|
|
|
|
|
time = ((ULONGLONG)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
|
|
|
|
|
|
|
|
buf->time = time / TICKSPERSEC - SECS_1601_TO_1970;
|
|
|
|
buf->millitm = (time % TICKSPERSEC) / TICKSPERMSEC;
|
2004-10-25 23:48:57 +02:00
|
|
|
buf->timezone = tzinfo.Bias +
|
|
|
|
( tzid == TIME_ZONE_ID_STANDARD ? tzinfo.StandardBias :
|
|
|
|
( tzid == TIME_ZONE_ID_DAYLIGHT ? tzinfo.DaylightBias : 0 ));
|
2004-03-11 01:43:47 +01:00
|
|
|
buf->dstflag = (tzid == TIME_ZONE_ID_DAYLIGHT?1:0);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
2003-03-04 03:19:15 +01:00
|
|
|
|
2004-06-25 03:19:15 +02:00
|
|
|
/*********************************************************************
|
2009-05-23 11:06:29 +02:00
|
|
|
* _ftime32 (MSVCRT.@)
|
2004-06-25 03:19:15 +02:00
|
|
|
*/
|
2009-05-23 11:06:29 +02:00
|
|
|
void CDECL MSVCRT__ftime32(struct MSVCRT___timeb32 *buf)
|
2004-06-25 03:19:15 +02:00
|
|
|
{
|
2009-05-23 11:06:29 +02:00
|
|
|
struct MSVCRT___timeb64 buf64;
|
2004-06-25 03:19:15 +02:00
|
|
|
|
2009-05-23 11:06:29 +02:00
|
|
|
MSVCRT__ftime64( &buf64 );
|
|
|
|
buf->time = buf64.time;
|
|
|
|
buf->millitm = buf64.millitm;
|
|
|
|
buf->timezone = buf64.timezone;
|
|
|
|
buf->dstflag = buf64.dstflag;
|
|
|
|
}
|
2004-06-25 03:19:15 +02:00
|
|
|
|
2009-05-23 11:06:29 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _ftime (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
#ifdef _WIN64
|
|
|
|
void CDECL MSVCRT__ftime(struct MSVCRT___timeb64 *buf)
|
|
|
|
{
|
|
|
|
return MSVCRT__ftime64( buf );
|
2004-06-25 03:19:15 +02:00
|
|
|
}
|
2009-05-23 11:06:29 +02:00
|
|
|
#else
|
|
|
|
void CDECL MSVCRT__ftime(struct MSVCRT___timeb32 *buf)
|
|
|
|
{
|
|
|
|
return MSVCRT__ftime32( buf );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _time64 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
MSVCRT___time64_t CDECL MSVCRT__time64(MSVCRT___time64_t *buf)
|
|
|
|
{
|
|
|
|
MSVCRT___time64_t curtime;
|
|
|
|
struct MSVCRT___timeb64 tb;
|
|
|
|
|
|
|
|
MSVCRT__ftime64(&tb);
|
|
|
|
|
|
|
|
curtime = tb.time;
|
|
|
|
return buf ? *buf = curtime : curtime;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _time32 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
MSVCRT___time32_t CDECL MSVCRT__time32(MSVCRT___time32_t *buf)
|
|
|
|
{
|
|
|
|
MSVCRT___time32_t curtime;
|
|
|
|
struct MSVCRT___timeb64 tb;
|
|
|
|
|
|
|
|
MSVCRT__ftime64(&tb);
|
|
|
|
|
|
|
|
curtime = tb.time;
|
|
|
|
return buf ? *buf = curtime : curtime;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* time (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
#ifdef _WIN64
|
|
|
|
MSVCRT___time64_t CDECL MSVCRT_time(MSVCRT___time64_t* buf)
|
|
|
|
{
|
|
|
|
return MSVCRT__time64( buf );
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
MSVCRT___time32_t CDECL MSVCRT_time(MSVCRT___time32_t* buf)
|
|
|
|
{
|
|
|
|
return MSVCRT__time32( buf );
|
|
|
|
}
|
|
|
|
#endif
|
2004-06-25 03:19:15 +02:00
|
|
|
|
2003-03-04 03:19:15 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _daylight (MSVCRT.@)
|
|
|
|
*/
|
2005-05-14 13:07:10 +02:00
|
|
|
int MSVCRT___daylight = 0;
|
2003-03-04 03:19:15 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __p_daylight (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int * CDECL MSVCRT___p__daylight(void)
|
2003-03-04 03:19:15 +01:00
|
|
|
{
|
|
|
|
return &MSVCRT___daylight;
|
|
|
|
}
|
2005-04-23 21:06:29 +02:00
|
|
|
|
2005-09-27 12:55:50 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _dstbias (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int MSVCRT__dstbias = 0;
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __p_dstbias (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int * CDECL __p__dstbias(void)
|
2005-09-27 12:55:50 +02:00
|
|
|
{
|
|
|
|
return &MSVCRT__dstbias;
|
|
|
|
}
|
|
|
|
|
2005-05-14 13:07:10 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _timezone (MSVCRT.@)
|
|
|
|
*/
|
2009-05-23 11:49:09 +02:00
|
|
|
MSVCRT_long MSVCRT___timezone = 0;
|
2005-05-14 13:07:10 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __p_timezone (MSVCRT.@)
|
|
|
|
*/
|
2009-05-23 11:49:09 +02:00
|
|
|
MSVCRT_long * CDECL MSVCRT___p__timezone(void)
|
2005-05-14 13:07:10 +02:00
|
|
|
{
|
|
|
|
return &MSVCRT___timezone;
|
|
|
|
}
|
|
|
|
|
2005-04-23 21:06:29 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _tzname (MSVCRT.@)
|
|
|
|
* NOTES
|
|
|
|
* Some apps (notably Mozilla) insist on writing to these, so the buffer
|
|
|
|
* must be large enough. The size is picked based on observation of
|
|
|
|
* Windows XP.
|
|
|
|
*/
|
2005-05-14 13:07:10 +02:00
|
|
|
static char tzname_std[64] = "";
|
|
|
|
static char tzname_dst[64] = "";
|
2005-04-23 21:06:29 +02:00
|
|
|
char *MSVCRT__tzname[2] = { tzname_std, tzname_dst };
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __p_tzname (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
char ** CDECL __p__tzname(void)
|
2005-04-23 21:06:29 +02:00
|
|
|
{
|
|
|
|
return MSVCRT__tzname;
|
|
|
|
}
|
2005-05-14 13:07:10 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _tzset (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
void CDECL MSVCRT__tzset(void)
|
2005-05-14 13:07:10 +02:00
|
|
|
{
|
|
|
|
tzset();
|
2005-05-24 13:52:46 +02:00
|
|
|
#if defined(HAVE_TIMEZONE) && defined(HAVE_DAYLIGHT)
|
2005-05-14 13:07:10 +02:00
|
|
|
MSVCRT___daylight = daylight;
|
|
|
|
MSVCRT___timezone = timezone;
|
2005-05-24 13:52:46 +02:00
|
|
|
#else
|
|
|
|
{
|
|
|
|
static const time_t seconds_in_year = (365 * 24 + 6) * 3600;
|
|
|
|
time_t t;
|
|
|
|
struct tm *tmp;
|
2009-05-23 11:49:09 +02:00
|
|
|
int zone_january, zone_july;
|
2005-05-24 13:52:46 +02:00
|
|
|
|
2010-03-29 00:01:53 +02:00
|
|
|
_mlock(_TIME_LOCK);
|
2008-12-05 07:47:01 +01:00
|
|
|
t = (time(NULL) / seconds_in_year) * seconds_in_year;
|
2005-05-24 13:52:46 +02:00
|
|
|
tmp = localtime(&t);
|
|
|
|
zone_january = -tmp->tm_gmtoff;
|
|
|
|
t += seconds_in_year / 2;
|
|
|
|
tmp = localtime(&t);
|
|
|
|
zone_july = -tmp->tm_gmtoff;
|
2010-03-29 00:01:53 +02:00
|
|
|
_munlock(_TIME_LOCK);
|
|
|
|
|
2005-05-24 13:52:46 +02:00
|
|
|
MSVCRT___daylight = (zone_january != zone_july);
|
|
|
|
MSVCRT___timezone = max(zone_january, zone_july);
|
|
|
|
}
|
|
|
|
#endif
|
2005-05-14 13:07:10 +02:00
|
|
|
lstrcpynA(tzname_std, tzname[0], sizeof(tzname_std));
|
|
|
|
tzname_std[sizeof(tzname_std) - 1] = '\0';
|
|
|
|
lstrcpynA(tzname_dst, tzname[1], sizeof(tzname_dst));
|
|
|
|
tzname_dst[sizeof(tzname_dst) - 1] = '\0';
|
|
|
|
}
|
2005-12-21 20:23:47 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
2006-01-14 17:22:03 +01:00
|
|
|
* strftime (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_size_t CDECL MSVCRT_strftime( char *str, MSVCRT_size_t max, const char *format,
|
|
|
|
const struct MSVCRT_tm *mstm )
|
2006-01-14 17:22:03 +01:00
|
|
|
{
|
|
|
|
struct tm tm;
|
|
|
|
|
|
|
|
msvcrt_tm_to_unix( &tm, mstm );
|
|
|
|
return strftime( str, max, format, &tm );
|
|
|
|
}
|
|
|
|
|
2006-01-23 19:29:15 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* wcsftime (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_size_t CDECL MSVCRT_wcsftime( MSVCRT_wchar_t *str, MSVCRT_size_t max,
|
|
|
|
const MSVCRT_wchar_t *format, const struct MSVCRT_tm *mstm )
|
2006-01-23 19:29:15 +01:00
|
|
|
{
|
2006-03-23 20:35:52 +01:00
|
|
|
char *s, *fmt;
|
|
|
|
MSVCRT_size_t len;
|
2006-01-23 19:29:15 +01:00
|
|
|
|
2008-12-11 21:01:38 +01:00
|
|
|
TRACE("%p %ld %s %p\n", str, max, debugstr_w(format), mstm );
|
2006-03-23 20:35:52 +01:00
|
|
|
|
|
|
|
len = WideCharToMultiByte( CP_UNIXCP, 0, format, -1, NULL, 0, NULL, NULL );
|
|
|
|
if (!(fmt = MSVCRT_malloc( len ))) return 0;
|
|
|
|
WideCharToMultiByte( CP_UNIXCP, 0, format, -1, fmt, len, NULL, NULL );
|
|
|
|
|
|
|
|
if ((s = MSVCRT_malloc( max*4 )))
|
|
|
|
{
|
|
|
|
struct tm tm;
|
|
|
|
msvcrt_tm_to_unix( &tm, mstm );
|
|
|
|
if (!strftime( s, max*4, fmt, &tm )) s[0] = 0;
|
|
|
|
len = MultiByteToWideChar( CP_UNIXCP, 0, s, -1, str, max );
|
|
|
|
if (len) len--;
|
|
|
|
MSVCRT_free( s );
|
|
|
|
}
|
|
|
|
else len = 0;
|
|
|
|
|
|
|
|
MSVCRT_free( fmt );
|
|
|
|
return len;
|
2006-01-23 19:29:15 +01:00
|
|
|
}
|
|
|
|
|
2006-01-14 17:22:03 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* asctime (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
char * CDECL MSVCRT_asctime(const struct MSVCRT_tm *mstm)
|
2006-01-14 17:22:03 +01:00
|
|
|
{
|
2010-09-28 10:47:56 +02:00
|
|
|
char bufferA[30];
|
|
|
|
WCHAR bufferW[30];
|
|
|
|
|
2006-01-14 17:22:03 +01:00
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
|
|
|
struct tm tm;
|
|
|
|
|
|
|
|
msvcrt_tm_to_unix( &tm, mstm );
|
|
|
|
|
|
|
|
if (!data->asctime_buffer)
|
|
|
|
data->asctime_buffer = MSVCRT_malloc( 30 ); /* ought to be enough */
|
|
|
|
|
|
|
|
#ifdef HAVE_ASCTIME_R
|
2010-09-28 10:47:56 +02:00
|
|
|
asctime_r( &tm, bufferA );
|
2006-01-14 17:22:03 +01:00
|
|
|
#else
|
2010-09-28 10:47:56 +02:00
|
|
|
strcpy( bufferA, asctime(&tm) );
|
2006-01-14 17:22:03 +01:00
|
|
|
#endif
|
2010-09-28 10:47:56 +02:00
|
|
|
MultiByteToWideChar( CP_UNIXCP, 0, bufferA, -1, bufferW, 30 );
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, bufferW, -1, data->asctime_buffer, 30, NULL, NULL );
|
2006-01-14 17:22:03 +01:00
|
|
|
return data->asctime_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _wasctime (MSVCRT.@)
|
2005-12-21 20:23:47 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_wchar_t * CDECL MSVCRT__wasctime(const struct MSVCRT_tm *mstm)
|
2006-01-14 17:22:03 +01:00
|
|
|
{
|
2005-12-21 20:23:47 +01:00
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
2006-01-14 17:22:03 +01:00
|
|
|
struct tm tm;
|
|
|
|
char buffer[30];
|
|
|
|
|
|
|
|
msvcrt_tm_to_unix( &tm, mstm );
|
2005-12-21 20:23:47 +01:00
|
|
|
|
|
|
|
if (!data->wasctime_buffer)
|
|
|
|
data->wasctime_buffer = MSVCRT_malloc( 30*sizeof(MSVCRT_wchar_t) ); /* ought to be enough */
|
2006-01-14 17:22:03 +01:00
|
|
|
#ifdef HAVE_ASCTIME_R
|
|
|
|
asctime_r( &tm, buffer );
|
|
|
|
#else
|
|
|
|
strcpy( buffer, asctime(&tm) );
|
|
|
|
#endif
|
|
|
|
MultiByteToWideChar( CP_UNIXCP, 0, buffer, -1, data->wasctime_buffer, 30 );
|
2005-12-21 20:23:47 +01:00
|
|
|
return data->wasctime_buffer;
|
|
|
|
}
|
|
|
|
|
2006-01-14 17:22:03 +01:00
|
|
|
/*********************************************************************
|
2009-05-23 11:06:29 +02:00
|
|
|
* _ctime64 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
char * CDECL MSVCRT__ctime64(const MSVCRT___time64_t *time)
|
|
|
|
{
|
|
|
|
struct MSVCRT_tm *t;
|
|
|
|
t = MSVCRT__localtime64( time );
|
|
|
|
if (!t) return NULL;
|
|
|
|
return MSVCRT_asctime( t );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _ctime32 (MSVCRT.@)
|
2006-01-14 17:22:03 +01:00
|
|
|
*/
|
2009-05-23 11:06:29 +02:00
|
|
|
char * CDECL MSVCRT__ctime32(const MSVCRT___time32_t *time)
|
2006-01-14 17:22:03 +01:00
|
|
|
{
|
2008-09-30 07:34:51 +02:00
|
|
|
struct MSVCRT_tm *t;
|
2009-05-23 11:06:29 +02:00
|
|
|
t = MSVCRT__localtime32( time );
|
2008-09-30 07:34:51 +02:00
|
|
|
if (!t) return NULL;
|
|
|
|
return MSVCRT_asctime( t );
|
2006-01-14 17:22:03 +01:00
|
|
|
}
|
|
|
|
|
2009-05-23 11:06:29 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* ctime (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
#ifdef _WIN64
|
|
|
|
char * CDECL MSVCRT_ctime(const MSVCRT___time64_t *time)
|
|
|
|
{
|
|
|
|
return MSVCRT__ctime64( time );
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
char * CDECL MSVCRT_ctime(const MSVCRT___time32_t *time)
|
|
|
|
{
|
|
|
|
return MSVCRT__ctime32( time );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _wctime64 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_wchar_t * CDECL MSVCRT__wctime64(const MSVCRT___time64_t *time)
|
|
|
|
{
|
|
|
|
return MSVCRT__wasctime( MSVCRT__localtime64(time) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _wctime32 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_wchar_t * CDECL MSVCRT__wctime32(const MSVCRT___time32_t *time)
|
|
|
|
{
|
|
|
|
return MSVCRT__wasctime( MSVCRT__localtime32(time) );
|
|
|
|
}
|
|
|
|
|
2005-12-21 20:23:47 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wctime (MSVCRT.@)
|
|
|
|
*/
|
2009-05-23 11:06:29 +02:00
|
|
|
#ifdef _WIN64
|
|
|
|
MSVCRT_wchar_t * CDECL MSVCRT__wctime(const MSVCRT___time64_t *time)
|
2005-12-21 20:23:47 +01:00
|
|
|
{
|
2009-05-23 11:06:29 +02:00
|
|
|
return MSVCRT__wctime64( time );
|
2005-12-21 20:23:47 +01:00
|
|
|
}
|
2009-05-23 11:06:29 +02:00
|
|
|
#else
|
|
|
|
MSVCRT_wchar_t * CDECL MSVCRT__wctime(const MSVCRT___time32_t *time)
|
|
|
|
{
|
|
|
|
return MSVCRT__wctime32( time );
|
|
|
|
}
|
|
|
|
#endif
|