All gmtime and localtime calls was rewritten to internal defined functions
This commit is contained in:
@@ -99,9 +99,9 @@ long GetFilesize(const char* file) {
|
||||
dword gfixstattime(time_t st_time) {
|
||||
|
||||
#if (defined(__MINGW32__) && !defined(__MSVCRT__)) || defined(__CYGWIN__)
|
||||
struct tm &f = *gmtime(&st_time);
|
||||
struct tm &f = *ggmtime(&st_time);
|
||||
#else
|
||||
struct tm &f = *localtime(&st_time);
|
||||
struct tm &f = *glocaltime(&st_time);
|
||||
#endif
|
||||
FFTime t;
|
||||
t.ft_year = f.tm_year - 80;
|
||||
|
@@ -109,7 +109,7 @@ void glog::printf(const char* format, ...) {
|
||||
char logbuf[256];
|
||||
|
||||
secs_now = time(NULL);
|
||||
time_now = localtime(&secs_now);
|
||||
time_now = glocaltime(&secs_now);
|
||||
|
||||
lineswritten++;
|
||||
|
||||
|
@@ -123,19 +123,39 @@ extern const char* gmonths[];
|
||||
// ------------------------------------------------------------------
|
||||
// Prototypes
|
||||
|
||||
#if defined(__WIN32__) && MAXINT > 0x0FFFFFFF // 64-bit
|
||||
extern struct tm dummy_struct_tm;
|
||||
inline struct tm* ggmtime(time_t* arg) {
|
||||
struct tm* a = gmtime(arg);
|
||||
return (a != NULL) ? a : &dummy_struct_tm;
|
||||
}
|
||||
inline struct tm* glocaltime(time_t* arg) {
|
||||
struct tm* a = localtime(arg);
|
||||
return (a != NULL) ? a : &dummy_struct_tm;
|
||||
}
|
||||
#define gmtime(arg) ggmtime(arg)
|
||||
#define localtime(arg) glocaltime(arg)
|
||||
inline struct tm *ggmtime(const time_t *timep)
|
||||
{
|
||||
#if defined(__WIN32__)
|
||||
const time_t zero(0);
|
||||
struct tm *time = gmtime(timep);
|
||||
return time ? time : gmtime(&zero);
|
||||
#else
|
||||
return gmtime(&timep);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline struct tm* glocaltime(const time_t *timep)
|
||||
{
|
||||
#if defined(__WIN32__)
|
||||
const time_t zero(0);
|
||||
struct tm *time = localtime(timep);
|
||||
return time ? time : localtime(&zero);
|
||||
#else
|
||||
return localtime(timep);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline struct tm* ggmtime(const time32_t *timep)
|
||||
{
|
||||
const time_t temp(*timep);
|
||||
return glocaltime(&temp);
|
||||
}
|
||||
|
||||
inline struct tm* glocaltime(const time32_t *timep)
|
||||
{
|
||||
const time_t temp(*timep);
|
||||
return glocaltime(&temp);
|
||||
}
|
||||
|
||||
#if defined(__OS2__)
|
||||
inline void usleep(long duration) { DosSleep(duration); }
|
||||
@@ -172,13 +192,6 @@ char* TimeToStr(char* buf, time_t t);
|
||||
long YMD2JDN(unsigned yr, unsigned mo, unsigned day) __attribute__ ((const));
|
||||
void JDN2YMD(long scalar, unsigned *yr, unsigned *mo, unsigned *day);
|
||||
|
||||
inline struct tm *gmtime(const time32_t *timep)
|
||||
{
|
||||
const time_t zero(0);
|
||||
const time_t temp(*timep);
|
||||
struct tm *time = gmtime(&temp);
|
||||
return time ? time : gmtime(&zero);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
@@ -43,13 +43,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#ifdef __WIN32__
|
||||
struct tm dummy_struct_tm = { 0, 0, 0, 1, 0, 70, 0, 0, -1 };
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
const char* gmonths[] = {
|
||||
@@ -68,7 +61,7 @@ const char* gmonths[] = {
|
||||
int tzoffset() {
|
||||
|
||||
time_t t1 = time(NULL);
|
||||
struct tm *tp = gmtime(&t1);
|
||||
struct tm *tp = ggmtime(&t1);
|
||||
tp->tm_isdst=-1;
|
||||
time_t t2 = mktime(tp);
|
||||
int dt = (int)(t1 - t2);
|
||||
@@ -358,7 +351,7 @@ time_t FTimeToTime(FTime* __ftime, struct tm* __tm) {
|
||||
__tm->tm_isdst = -1;
|
||||
|
||||
time_t a = mktime(__tm);
|
||||
struct tm *tp = gmtime(&a);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
_time = a + a - b;
|
||||
@@ -382,7 +375,7 @@ FTime TimeToFTime(time_t __time) {
|
||||
|
||||
if(__time) {
|
||||
|
||||
struct tm* _tmp = gmtime(&__time);
|
||||
struct tm* _tmp = ggmtime(&__time);
|
||||
_ft.ft_year = (word)(_tmp->tm_year - 80);
|
||||
_ft.ft_month = (word)(_tmp->tm_mon + 1);
|
||||
_ft.ft_day = (word)(_tmp->tm_mday);
|
||||
@@ -449,7 +442,7 @@ time_t FidoTimeToUnix(char* ptr) {
|
||||
t.tm_sec = second;
|
||||
t.tm_isdst = -1;
|
||||
time_t a = mktime(&t);
|
||||
struct tm *tp = gmtime(&a);
|
||||
struct tm *tp = ggmtime(&a);
|
||||
tp->tm_isdst = -1;
|
||||
time_t b = mktime(tp);
|
||||
return a + a - b;
|
||||
@@ -462,7 +455,7 @@ time_t FidoTimeToUnix(char* ptr) {
|
||||
|
||||
char* TimeToStr(char* buf, time_t t) {
|
||||
|
||||
return strftimei(buf, 20, "%Y-%m-%d %H:%M:%S", gmtime(&t));
|
||||
return strftimei(buf, 20, "%Y-%m-%d %H:%M:%S", ggmtime(&t));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user