summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2025-10-31 08:05:33 +0100
committerPeter Eisentraut <peter@eisentraut.org>2025-10-31 08:06:46 +0100
commitce5f6817e4d572300f303a797f4f42820ead0044 (patch)
tree4a0130b00a5a7449bf66a84c11dd922d9ecb6274
parentc9e38a569c5fe8006a08f63ba6b63d8021704c53 (diff)
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. Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/6dd9d208-a3ed-49b5-b03d-8617261da973%40eisentraut.org
-rw-r--r--src/backend/utils/adt/formatting.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index 2e5e1328192..b1e6e76fafc 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;
@@ -454,7 +451,7 @@ struct fmt_tz /* do_to_timestamp's timezone info output */
(_X)->mode, (_X)->hh, (_X)->pm, (_X)->mi, (_X)->ss, (_X)->ssss, \
(_X)->d, (_X)->dd, (_X)->ddd, (_X)->mm, (_X)->ms, (_X)->year, \
(_X)->bc, (_X)->ww, (_X)->w, (_X)->cc, (_X)->j, (_X)->us, \
- (_X)->yysz, (_X)->clock)
+ (_X)->yysz, (_X)->clock_12_hour)
#define DEBUG_TM(_X) \
elog(DEBUG_elog_output, "TM:\nsec %d\nyear %d\nmin %d\nwday %d\nhour %d\nyday %d\nmday %d\nnisdst %d\nmon %d\n",\
(_X)->tm_sec, (_X)->tm_year,\
@@ -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(const text *date_txt, const 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)
{