Jeff Smith : ucrtbase: Extend range for seconds to allow for leap-second.

Alexandre Julliard julliard at winehq.org
Fri Nov 22 16:17:25 CST 2019


Module: wine
Branch: master
Commit: 15bbe646099bd9babbf5be672960ee4e458eb33b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=15bbe646099bd9babbf5be672960ee4e458eb33b

Author: Jeff Smith <whydoubt at gmail.com>
Date:   Thu Nov 21 18:28:07 2019 -0600

ucrtbase: Extend range for seconds to allow for leap-second.

Signed-off-by: Jeff Smith <whydoubt at gmail.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcrt/time.c         | 12 +++++++++---
 dlls/ucrtbase/tests/misc.c |  2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c
index 8534738406..802032d79e 100644
--- a/dlls/msvcrt/time.c
+++ b/dlls/msvcrt/time.c
@@ -54,6 +54,12 @@ static const int MonthLengths[2][12] =
     { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
 };
 
+#if _MSVCR_VER>=140
+static const int MAX_SECONDS = 60;
+#else
+static const int MAX_SECONDS = 59;
+#endif
+
 static inline BOOL IsLeapYear(int Year)
 {
     return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0);
@@ -1141,7 +1147,7 @@ static inline BOOL strftime_format(STRFTIME_CHAR *str, MSVCRT_size_t *pos, MSVCR
             if(count > 2)
                 ret = strftime_nstr(str, pos, max, format, count-2);
             if(ret)
-                ret = strftime_int(str, pos, max, mstm->tm_sec, count == 1 ? 0 : 2, 0, 59);
+                ret = strftime_int(str, pos, max, mstm->tm_sec, count == 1 ? 0 : 2, 0, MAX_SECONDS);
             break;
         case 'a':
         case 'A':
@@ -1381,7 +1387,7 @@ static MSVCRT_size_t strftime_impl(STRFTIME_CHAR *str, MSVCRT_size_t max,
             break;
 #endif
         case 'S':
-            if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, 59))
+            if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, MAX_SECONDS))
                 return 0;
             break;
 #if _MSVCR_VER>=140
@@ -1397,7 +1403,7 @@ static MSVCRT_size_t strftime_impl(STRFTIME_CHAR *str, MSVCRT_size_t max,
                 return 0;
             if(ret < max)
                 str[ret++] = ':';
-            if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, 59))
+            if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, MAX_SECONDS))
                 return 0;
             break;
         case 'u':
diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c
index 9c5045b66a..154781dd33 100644
--- a/dlls/ucrtbase/tests/misc.c
+++ b/dlls/ucrtbase/tests/misc.c
@@ -1004,7 +1004,7 @@ static void test_strftime(void)
         {"%#x", "", { 0, 0, 0, 30, 12, 70, 4, 0, 0 }},
         {"%X", "00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
         {"%X", "14:00:00", { 0, 0, 14, 1, 0, 70, 4, 0, 0 }},
-        {"%X", "23:59:60", { 60, 59, 23, 1, 0, 70, 4, 0, 0 }, TRUE},
+        {"%X", "23:59:60", { 60, 59, 23, 1, 0, 70, 4, 0, 0 }},
     };
 
     const struct {




More information about the wine-cvs mailing list