forked from enlightenment/efl
evil: Implement evil_localtime_r using localtime
Implements `evil_localtime_r` using win32 [localtime function](https://docs.microsoft.com/pt-br/cpp/c-runtime-library/reference/localtime-localtime32-localtime64?view=vs-2019). If `HAVE_lOCALTIME_R` is not defined, define `localtime_r` as `evil_localtime_r` Co-authored-by: Felipe Magno de Almeida <felipe@expertise.dev>
This commit is contained in:
parent
9407a5fe76
commit
38a94040a2
|
@ -88,6 +88,7 @@ function_checks = [
|
|||
['getxattr', ['sys/types.h', 'sys/xattr.h']],
|
||||
['iconv', ['iconv.h']],
|
||||
['listxattr', ['sys/types.h', 'sys/xattr.h']],
|
||||
['localtime_r', ['time.h']],
|
||||
['malloc_info', ['malloc.h']],
|
||||
['malloc_usable_size', ['malloc.h']],
|
||||
['mkdirat', ['sys/stat.h']],
|
||||
|
|
|
@ -61,6 +61,19 @@ int evil_gettimeofday(struct timeval *tv, struct timezone *tz)
|
|||
return res;
|
||||
}
|
||||
|
||||
EVIL_API struct tm *
|
||||
evil_localtime_r(const time_t * time, struct tm * result)
|
||||
{
|
||||
struct tm* _result = localtime(time);
|
||||
|
||||
if (_result)
|
||||
{
|
||||
*result = *_result;
|
||||
return result;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* strptime
|
||||
* based on http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/time/strptime.c?rev=HEAD
|
||||
|
@ -468,8 +481,15 @@ strptime(const char *buf, const char *fmt, struct tm *tm)
|
|||
}
|
||||
else
|
||||
{
|
||||
TIME_ZONE_INFORMATION zone_info;
|
||||
GetTimeZoneInformation(&zone_info);
|
||||
const char timezone_table[3] = {
|
||||
zone_info.StandardName,
|
||||
zone_info.DaylightName,
|
||||
NULL,
|
||||
};
|
||||
ep = find_string(bp, &i,
|
||||
(const char * const *)tzname,
|
||||
(const char * const *)timezone_table,
|
||||
NULL, 2);
|
||||
if (ep != NULL)
|
||||
{
|
||||
|
|
|
@ -43,6 +43,12 @@ EVIL_API int evil_gettimeofday(struct timeval *tv, struct timezone *tz);
|
|||
# define HAVE_GETTIMEOFDAY 1
|
||||
#endif
|
||||
|
||||
EVIL_API struct tm *evil_localtime_r(const time_t * time, struct tm * result);
|
||||
|
||||
#ifndef HAVE_LOCALTIME_R
|
||||
# define HAVE_LOCALTIME_R
|
||||
# define localtime_r evil_localtime_r
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Convert a string representation of time to a time tm structure .
|
||||
|
|
Loading…
Reference in New Issue