From 5c06aec1a9c00aef4042602c5c7e8a2d694e0009 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 20 Oct 2025 08:16:03 +0200 Subject: [PATCH v1 10/13] formatting.c cleanup: Change TmFromChar.clock field to bool This makes the purpose clearer and avoids having two extra symbols, one of which (CLOCK_24_HOUR) was unused. --- src/backend/utils/adt/formatting.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index cab3d4374c0..532ed7ab2ad 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -162,9 +162,6 @@ typedef struct #define SUFFTYPE_PREFIX 1 #define SUFFTYPE_POSTFIX 2 -#define CLOCK_24_HOUR 0 -#define CLOCK_12_HOUR 1 - /* * Full months @@ -428,7 +425,7 @@ typedef struct int j; int us; int yysz; /* is it YY or YYYY ? */ - int clock; /* 12 or 24 hour clock? */ + bool clock_12_hour; /* 12 or 24 hour clock? */ int tzsign; /* +1, -1, or 0 if no TZH/TZM fields */ int tzh; int tzm; @@ -3225,7 +3222,7 @@ DCH_from_char(FormatNode *node, const char *in, TmFromChar *out, return; if (!from_char_set_int(&out->pm, value % 2, n, escontext)) return; - out->clock = CLOCK_12_HOUR; + out->clock_12_hour = true; break; case DCH_AM: case DCH_PM: @@ -3237,13 +3234,13 @@ DCH_from_char(FormatNode *node, const char *in, TmFromChar *out, return; if (!from_char_set_int(&out->pm, value % 2, n, escontext)) return; - out->clock = CLOCK_12_HOUR; + out->clock_12_hour = true; break; case DCH_HH: case DCH_HH12: if (from_char_parse_int_len(&out->hh, &s, 2, n, escontext) < 0) return; - out->clock = CLOCK_12_HOUR; + out->clock_12_hour = true; SKIP_THth(s, n->suffix); break; case DCH_HH24: @@ -4456,7 +4453,7 @@ do_to_timestamp(text *date_txt, text *fmt, Oid collid, bool std, if (tmfc.hh) tm->tm_hour = tmfc.hh; - if (tmfc.clock == CLOCK_12_HOUR) + if (tmfc.clock_12_hour) { if (tm->tm_hour < 1 || tm->tm_hour > HOURS_PER_DAY / 2) { -- 2.51.0