Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/msvcrt/time.c | 26 ++++++++++++++++++++++++++ dlls/ucrtbase/tests/misc.c | 6 ++++++ 2 files changed, 32 insertions(+)
diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c index 9787d18e3f..3f378b0d1a 100644 --- a/dlls/msvcrt/time.c +++ b/dlls/msvcrt/time.c @@ -1033,6 +1033,26 @@ static inline BOOL strftime_time(char *str, MSVCRT_size_t *pos, MSVCRT_size_t ma return TRUE; }
+static inline BOOL strftime_tzdiff(char *str, MSVCRT_size_t *pos, MSVCRT_size_t max, int dst) +{ + MSVCRT_size_t len; + MSVCRT_long tz = MSVCRT___timezone + (dst * MSVCRT__dstbias); + + char sign = (tz > 0) ? '-' : '+'; + unsigned int minutes = ((tz < 0) ? -tz : tz) / 60; + unsigned int hours = minutes / 60; + + len = MSVCRT__snprintf(str+*pos, max-*pos, "%c%02u%02u", sign, hours, minutes % 60); + if(*pos + len > max) { + *str = 0; + *MSVCRT__errno() = MSVCRT_ERANGE; + return FALSE; + } + + *pos += len; + return TRUE; +} + static inline BOOL strftime_str(char *str, MSVCRT_size_t *pos, MSVCRT_size_t max, char *src) { MSVCRT_size_t len = strlen(src); @@ -1300,6 +1320,12 @@ static MSVCRT_size_t strftime_helper(char *str, MSVCRT_size_t max, const char *f return 0; break; case 'z': +#if _MSVCR_VER>=140 + MSVCRT__tzset(); + if(!strftime_tzdiff(str, &ret, max, mstm->tm_isdst ? 1 : 0)) + return 0; + break; +#endif case 'Z': MSVCRT__tzset(); if(MSVCRT__get_tzname(&tmp, str+ret, max-ret, mstm->tm_isdst ? 1 : 0)) diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c index 3a1598fee2..014d66d595 100644 --- a/dlls/ucrtbase/tests/misc.c +++ b/dlls/ucrtbase/tests/misc.c @@ -1005,6 +1005,12 @@ static void test_strftime(void) todo_wine ok(retA == 2, "expected 2, got %d\n", (int)retA); todo_wine ok(!strcmp(bufA, "53"), "got %s\n", bufA);
+ retA = p_strftime(bufA, sizeof(bufA), "%z", &tm2); + ok(retA == 5, "expected 5, got %d\n", (int)retA); + ok((bufA[0] == '+' || bufA[0] == '-') && + isdigit(bufA[1]) && isdigit(bufA[2]) && + isdigit(bufA[3]) && isdigit(bufA[4]), "got %s\n", bufA); + for(i=0; i<14; i++) { __time32_t t = (365*2 + i - 7) * 24 * 60 * 60;