Query about time zone patterns in to_char

From: Nitin Jadhav <nitinjadhavpostgres(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Query about time zone patterns in to_char
Date: 2021-05-16 14:55:48
Message-ID: CAMm1aWZ-oZyKd75+8D=VJ0sAoSwtdXWLP-MAWD4D8R1Dgandzw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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(at)123613=#select to_char(current_timestamp, 'TZH');
to_char
---------
+05
(1 row)

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

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

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

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

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

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

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

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

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

Thanks & Regards,
Nitin Jadhav

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-05-16 15:10:05 Re: Query about time zone patterns in to_char
Previous Message Etsuro Fujita 2021-05-16 14:39:14 Re: Asynchronous Append on postgres_fdw nodes.