diff options
| author | 2026-01-15 18:06:49 -0800 | |
|---|---|---|
| committer | 2026-01-22 13:26:30 +0100 | |
| commit | 287e7e7fd6f221985a325bef66b8a81e8dda1062 (patch) | |
| tree | c14ad5fcb536e59323384e4006f57486e3a91b9f /src | |
| parent | 06d92b11523115b5813ee3235f6ea052b98e6d2d (diff) | |
| download | libplist-287e7e7fd6f221985a325bef66b8a81e8dda1062.tar.gz libplist-287e7e7fd6f221985a325bef66b8a81e8dda1062.tar.bz2 | |
time64: Add time_s support for WIN32
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/time64.c | 4 | ||||
| -rw-r--r-- | src/time64.h | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/time64.c b/src/time64.c index cfbe7ac..218088e 100644 --- a/src/time64.c +++ b/src/time64.c | |||
| @@ -443,7 +443,7 @@ void copy_TM64_to_tm(const struct TM *src, struct tm *dest) { | |||
| 443 | } | 443 | } |
| 444 | 444 | ||
| 445 | 445 | ||
| 446 | #ifndef HAVE_LOCALTIME_R | 446 | #if !defined(HAVE_LOCALTIME_R) && !defined(_WIN32) |
| 447 | /* Simulate localtime_r() to the best of our ability */ | 447 | /* Simulate localtime_r() to the best of our ability */ |
| 448 | static struct tm * fake_localtime_r(const time_t *time, struct tm *result) { | 448 | static struct tm * fake_localtime_r(const time_t *time, struct tm *result) { |
| 449 | const struct tm *static_result = localtime(time); | 449 | const struct tm *static_result = localtime(time); |
| @@ -462,7 +462,7 @@ static struct tm * fake_localtime_r(const time_t *time, struct tm *result) { | |||
| 462 | #endif | 462 | #endif |
| 463 | 463 | ||
| 464 | 464 | ||
| 465 | #ifndef HAVE_GMTIME_R | 465 | #if !defined(HAVE_GMTIME_R) && !defined(_WIN32) |
| 466 | /* Simulate gmtime_r() to the best of our ability */ | 466 | /* Simulate gmtime_r() to the best of our ability */ |
| 467 | static struct tm * fake_gmtime_r(const time_t *time, struct tm *result) { | 467 | static struct tm * fake_gmtime_r(const time_t *time, struct tm *result) { |
| 468 | const struct tm *static_result = gmtime(time); | 468 | const struct tm *static_result = gmtime(time); |
diff --git a/src/time64.h b/src/time64.h index efdc716..28968c0 100644 --- a/src/time64.h +++ b/src/time64.h | |||
| @@ -58,11 +58,15 @@ Time64_T timelocal64 (struct TM *); | |||
| 58 | /* Not everyone has gm/localtime_r(), provide a replacement */ | 58 | /* Not everyone has gm/localtime_r(), provide a replacement */ |
| 59 | #ifdef HAVE_LOCALTIME_R | 59 | #ifdef HAVE_LOCALTIME_R |
| 60 | # define LOCALTIME_R(clock, result) localtime_r(clock, result) | 60 | # define LOCALTIME_R(clock, result) localtime_r(clock, result) |
| 61 | #elif defined(_WIN32) | ||
| 62 | # define LOCALTIME_R(clock, result) (localtime_s(result, clock) ? NULL : result) | ||
| 61 | #else | 63 | #else |
| 62 | # define LOCALTIME_R(clock, result) fake_localtime_r(clock, result) | 64 | # define LOCALTIME_R(clock, result) fake_localtime_r(clock, result) |
| 63 | #endif | 65 | #endif |
| 64 | #ifdef HAVE_GMTIME_R | 66 | #ifdef HAVE_GMTIME_R |
| 65 | # define GMTIME_R(clock, result) gmtime_r(clock, result) | 67 | # define GMTIME_R(clock, result) gmtime_r(clock, result) |
| 68 | #elif defined (_WIN32) | ||
| 69 | # define GMTIME_R(clock, result) (gmtime_s(result, clock) ? NULL : result) | ||
| 66 | #else | 70 | #else |
| 67 | # define GMTIME_R(clock, result) fake_gmtime_r(clock, result) | 71 | # define GMTIME_R(clock, result) fake_gmtime_r(clock, result) |
| 68 | #endif | 72 | #endif |
