Use SECS_PER_HOUR macro in tzparser.c, instead of constants

Reported-by: CharSyam

Discussion: https://postgr.es/m/CAMrLSE5j_aWfoBDMrSvk14oBKSy+-2cjzNNH_FciirA7Kwo9TA@mail.gmail.com

Author: CharSyam

Backpatch-through: master
This commit is contained in:
Bruce Momjian 2023-11-24 22:36:23 -05:00
parent 9890a855ae
commit 79588d3c8d
1 changed files with 4 additions and 3 deletions

View 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);
}