diff options
author | heikki@donna.mysql.fi <> | 2001-05-24 22:59:32 +0300 |
---|---|---|
committer | heikki@donna.mysql.fi <> | 2001-05-24 22:59:32 +0300 |
commit | 0703dba10da45c58d6abd9ed976ac17c14d26eed (patch) | |
tree | d12ea616a8230d164b6a4571dada572b09b714c4 /innobase/ut | |
parent | 125b4bd6bac3403baf2bf14e8d17d35656873c03 (diff) | |
download | mariadb-git-0703dba10da45c58d6abd9ed976ac17c14d26eed.tar.gz |
ut0ut.c Rewrote ut_print_timestamp with localtime_r and in Win GetLocalTime
Diffstat (limited to 'innobase/ut')
-rw-r--r-- | innobase/ut/ut0ut.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c index cae0c3819f3..07ee3d2b6fe 100644 --- a/innobase/ut/ut0ut.c +++ b/innobase/ut/ut0ut.c @@ -57,25 +57,26 @@ ut_print_timestamp( /*===============*/ FILE* file) /* in: file where to print */ { - struct tm* cal_tm_ptr; - struct tm cal_tm; - time_t tm; +#ifdef __WIN__ + SYSTEMTIME cal_tm; - try_again: - time(&tm); + GetLocalTime(&cal_tm); - cal_tm_ptr = localtime(&tm); - - memcpy(&cal_tm, cal_tm_ptr, sizeof(struct tm)); + fprintf(file,"%02d%02d%02d %2d:%02d:%02d", + (int)cal_tm.wYear % 100, + (int)cal_tm.wMonth, + (int)cal_tm.wDay, + (int)cal_tm.wHour, + (int)cal_tm.wMinute, + (int)cal_tm.wSecond); +#else - /* In theory localtime may return a wrong result because its return - struct is not protected with a mutex */ + struct tm cal_tm; + time_t tm; - if (difftime(tm, mktime(&cal_tm)) > 0.5 - || difftime(tm, mktime(&cal_tm)) < -0.5) { + time(&tm); - goto try_again; - } + localtime_r(&tm, &cal_tm); fprintf(file,"%02d%02d%02d %2d:%02d:%02d", cal_tm.tm_year % 100, @@ -84,6 +85,7 @@ ut_print_timestamp( cal_tm.tm_hour, cal_tm.tm_min, cal_tm.tm_sec); +#endif } /***************************************************************** |