Query about time zone patterns in to_char

Nitin Jadhav <nitinjadhavpostgres@gmail.com>

From: Nitin Jadhav <nitinjadhavpostgres@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-05-16T14:55:48Z
Lists: pgsql-hackers
Hi Hackers,

While understanding the behaviour of the to_char() function as
explained in [1], I observed that some patterns related to time zones
do not display values if we mention in lower case. As shown in the
sample output [2], time zone related patterns TZH, TZM and OF outputs
proper values when specified in upper case but does not work if we
mention in lower case. But other patterns like TZ, HH, etc works fine
with upper case as well as lower case.

I would like to know whether the current behaviour of TZH, TZM and OF
is done intentionally and is as expected.
Please share your thoughts.

[1] - https://www.postgresql.org/docs/current/functions-formatting.html

[2] -
postgres@123613=#select to_char(current_timestamp, 'TZH');
 to_char
---------
 +05
(1 row)

postgres@123613=#select to_char(current_timestamp, 'TZM');
 to_char
---------
 30
(1 row)

postgres@123613=#select to_char(current_timestamp, 'OF');
 to_char
---------
 +05:30
(1 row)

postgres@123613=#select to_char(current_timestamp, 'tzh');
 to_char
---------
 isth
(1 row)

postgres@123613=#select to_char(current_timestamp, 'tzm');
 to_char
---------
 istm
(1 row)

postgres@123613=#select to_char(current_timestamp, 'of');
 to_char
---------
 of
(1 row)

[3] -
postgres@123613=#select to_char(current_timestamp, 'tz');
 to_char
---------
 ist
(1 row)

postgres@123613=#select to_char(current_timestamp, 'TZ');
 to_char
---------
 IST
(1 row)

postgres@123613=#select to_char(current_timestamp, 'HH');
 to_char
---------
 08
(1 row)

postgres@123613=#select to_char(current_timestamp, 'hh');
 to_char
---------
 08
(1 row)

Thanks & Regards,
Nitin Jadhav



Commits

  1. Support "of", "tzh", and "tzm" format codes.

  2. Implement TZH and TZM timestamp format patterns