1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-04 20:11:56 +03:00

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
This commit is contained in:
Peter Eisentraut
2025-10-31 08:05:33 +01:00
parent c9e38a569c
commit ce5f6817e4

View File

@@ -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)
{