Use SECS_PER_HOUR macro in tzparser.c, instead of constants
authorBruce Momjian <[email protected]>
Sat, 25 Nov 2023 03:36:23 +0000 (22:36 -0500)
committerBruce Momjian <[email protected]>
Sat, 25 Nov 2023 03:36:23 +0000 (22:36 -0500)
Reported-by: CharSyam
Discussion: https://postgr.es/m/CAMrLSE5j_aWfoBDMrSvk14oBKSy+-2cjzNNH_FciirA7Kwo9TA@mail.gmail.com

Author: CharSyam

Back-through: master

src/backend/utils/misc/tzparser.c

index dfb0253150e1c08cbfd4ca1286e0b6095a07c53b..8da529de5661dba816a8fed9828b42a789bd4709 100644 (file)
@@ -29,6 +29,7 @@
 #include "utils/guc.h"
 #include "utils/memutils.h"
 #include "utils/tzparser.h"
+#include "utils/datetime.h"
 
 
 #define WHITESPACE " \t\n\r"
@@ -66,8 +67,8 @@ validateTzEntry(tzEntry *tzentry)
    /*
     * Sanity-check the offset: shouldn't exceed 14 hours
     */
-   if (tzentry->offset > 14 * 60 * 60 ||
-       tzentry->offset < -14 * 60 * 60)
+   if (tzentry->offset > 14 * SECS_PER_HOUR ||
+       tzentry->offset < -14 * SECS_PER_HOUR)
    {
        GUC_check_errmsg("time zone offset %d is out of range in time zone file \"%s\", line %d",
                         tzentry->offset,
@@ -155,7 +156,7 @@ splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry)
         * zones that probably will never be used in the current session.
         */
        tzentry->zone = pstrdup(offset);
-       tzentry->offset = 0;
+       tzentry->offset = 0 * SECS_PER_HOUR;
        tzentry->is_dst = false;
        remain = strtok(NULL, WHITESPACE);
    }