From bc69f0b356f1820fedcf254ccd6553fbca7d0cc2 Mon Sep 17 00:00:00 2001 From: chagelo Date: Thu, 21 Nov 2024 17:36:20 +0800 Subject: [PATCH] * add `timezone(zone, timestamptz)` testcases Signed-off-by: chagelo --- .../regress/data/expected/timestamptz.out | 187 ++++++++++++++++++ src/tests/regress/data/sql/timestamptz.sql | 36 ++++ 2 files changed, 223 insertions(+) diff --git a/src/tests/regress/data/expected/timestamptz.out b/src/tests/regress/data/expected/timestamptz.out index 9b88cdf1916a1..29fc1c4b089ca 100644 --- a/src/tests/regress/data/expected/timestamptz.out +++ b/src/tests/regress/data/expected/timestamptz.out @@ -2636,6 +2636,193 @@ SELECT '2014-10-26 02:00:00'::timestamp AT TIME ZONE 'MSK'; 2014-10-25 23:00:00+00 (1 row) +SELECT timezone('Asia/Shanghai', '2024-11-20 20:00:00 UTC'::timestamptz); + timezone +--------------------- + 2024-11-21 04:00:00 +(1 row) + +SELECT timezone('Asia/Shanghai', '2023-02-28 20:00:00 UTC'::timestamptz); + timezone +--------------------- + 2023-03-01 04:00:00 +(1 row) + +SELECT timezone('Asia/Shanghai', '2024-02-28 20:00:00 UTC'::timestamptz); + timezone +--------------------- + 2024-02-29 04:00:00 +(1 row) + +SELECT timezone('Europe/Moscow', '2011-03-26 22:00:00 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 01:00:00 +(1 row) + +SELECT timezone('Europe/Moscow', '2011-03-26 22:59:59 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 01:59:59 +(1 row) + +SELECT timezone('Europe/Moscow', '2011-03-26 23:00:00 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 03:00:00 +(1 row) + +SELECT timezone('Europe/Moscow', '2011-03-26 23:00:01 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 03:00:01 +(1 row) + +SELECT timezone('Europe/Moscow', '2011-03-27 01:00:00 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 05:00:00 +(1 row) + +SELECT timezone('Europe/Moscow', '2011-03-27 02:00:00 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 06:00:00 +(1 row) + +SELECT timezone('Europe/Moscow', '2011-03-27 02:59:59 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 06:59:59 +(1 row) + +SELECT timezone('Europe/Moscow', '2011-03-27 03:00:00 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 07:00:00 +(1 row) + +SELECT timezone('MSK', '2011-03-26 22:00:00 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 01:00:00 +(1 row) + +SELECT timezone('MSK', '2011-03-26 22:59:59 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 01:59:59 +(1 row) + +SELECT timezone('MSK', '2011-03-26 23:00:00 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 03:00:00 +(1 row) + +SELECT timezone('MSK', '2011-03-26 23:00:01 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 03:00:01 +(1 row) + +SELECT timezone('MSK', '2011-03-27 01:00:00 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 05:00:00 +(1 row) + +SELECT timezone('MSK', '2011-03-27 02:00:00 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 06:00:00 +(1 row) + +SELECT timezone('MSK', '2011-03-27 02:59:59 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 06:59:59 +(1 row) + +SELECT timezone('MSK', '2011-03-27 03:00:00 UTC'::timestamptz); + timezone +--------------------- + 2011-03-27 07:00:00 +(1 row) + + +SELECT timezone('Europe/Moscow', '2014-10-25 21:59:59 UTC'::timestamptz); + timezone +--------------------- + 2014-10-26 01:59:59 +(1 row) + +SELECT timezone('Europe/Moscow', '2014-10-25 22:00:00 UTC'::timestamptz); + timezone +--------------------- + 2014-10-26 01:00:00 +(1 row) + +SELECT timezone('Europe/Moscow', '2014-10-25 22:59:59 UTC'::timestamptz); + timezone +--------------------- + 2014-10-26 01:59:59 +(1 row) + +SELECT timezone('Europe/Moscow', '2014-10-25 23:00:00 UTC'::timestamptz); + timezone +--------------------- + 2014-10-26 02:00:00 +(1 row) + +SELECT timezone('Europe/Moscow', '2014-10-25 23:00:01 UTC'::timestamptz); + timezone +--------------------- + 2014-10-26 02:00:01 +(1 row) + +SELECT timezone('Europe/Moscow', '2014-10-26 02:00:01 UTC'::timestamptz); + timezone +--------------------- + 2014-10-26 05:00:01 +(1 row) + +SELECT timezone('MSK', '2014-10-25 21:59:59 UTC'::timestamptz); + timezone +--------------------- + 2014-10-26 01:59:59 +(1 row) + +SELECT timezone('MSK', '2014-10-25 22:00:00 UTC'::timestamptz); + timezone +--------------------- + 2014-10-26 01:00:00 +(1 row) + +SELECT timezone('MSK', '2014-10-25 22:59:59 UTC'::timestamptz); + timezone +--------------------- + 2014-10-26 01:59:59 +(1 row) + +SELECT timezone('MSK', '2014-10-25 23:00:00 UTC'::timestamptz); + timezone +--------------------- + 2014-10-26 02:00:00 +(1 row) + +SELECT timezone('MSK', '2014-10-25 23:00:01 UTC'::timestamptz); + timezone +--------------------- + 2014-10-26 02:00:01 +(1 row) + +SELECT timezone('MSK', '2014-10-26 02:00:01 UTC'::timestamptz); + timezone +--------------------- + 2014-10-26 05:00:01 +(1 row) + SELECT make_timestamptz(2014, 10, 26, 0, 0, 0, 'MSK'); make_timestamptz ------------------------ diff --git a/src/tests/regress/data/sql/timestamptz.sql b/src/tests/regress/data/sql/timestamptz.sql index ca2877024d58d..296e5021a8494 100644 --- a/src/tests/regress/data/sql/timestamptz.sql +++ b/src/tests/regress/data/sql/timestamptz.sql @@ -480,6 +480,42 @@ SELECT '2014-10-26 01:00:00'::timestamp AT TIME ZONE 'MSK'; SELECT '2014-10-26 01:00:01'::timestamp AT TIME ZONE 'MSK'; SELECT '2014-10-26 02:00:00'::timestamp AT TIME ZONE 'MSK'; +SELECT timezone('Asia/Shanghai', '2024-11-20 20:00:00 UTC'::timestamptz); +SELECT timezone('Asia/Shanghai', '2023-02-28 20:00:00 UTC'::timestamptz); +SELECT timezone('Asia/Shanghai', '2024-02-28 20:00:00 UTC'::timestamptz); + +SELECT timezone('Europe/Moscow', '2011-03-26 22:00:00 UTC'::timestamptz); +SELECT timezone('Europe/Moscow', '2011-03-26 22:59:59 UTC'::timestamptz); +SELECT timezone('Europe/Moscow', '2011-03-26 23:00:00 UTC'::timestamptz); +SELECT timezone('Europe/Moscow', '2011-03-26 23:00:01 UTC'::timestamptz); +SELECT timezone('Europe/Moscow', '2011-03-27 01:00:00 UTC'::timestamptz); +SELECT timezone('Europe/Moscow', '2011-03-27 02:00:00 UTC'::timestamptz); +SELECT timezone('Europe/Moscow', '2011-03-27 02:59:59 UTC'::timestamptz); +SELECT timezone('Europe/Moscow', '2011-03-27 03:00:00 UTC'::timestamptz); + +SELECT timezone('MSK', '2011-03-26 22:00:00 UTC'::timestamptz); +SELECT timezone('MSK', '2011-03-26 22:59:59 UTC'::timestamptz); +SELECT timezone('MSK', '2011-03-26 23:00:00 UTC'::timestamptz); +SELECT timezone('MSK', '2011-03-26 23:00:01 UTC'::timestamptz); +SELECT timezone('MSK', '2011-03-27 01:00:00 UTC'::timestamptz); +SELECT timezone('MSK', '2011-03-27 02:00:00 UTC'::timestamptz); +SELECT timezone('MSK', '2011-03-27 02:59:59 UTC'::timestamptz); +SELECT timezone('MSK', '2011-03-27 03:00:00 UTC'::timestamptz); + +SELECT timezone('Europe/Moscow', '2014-10-25 21:59:59 UTC'::timestamptz); +SELECT timezone('Europe/Moscow', '2014-10-25 22:00:00 UTC'::timestamptz); +SELECT timezone('Europe/Moscow', '2014-10-25 22:59:59 UTC'::timestamptz); +SELECT timezone('Europe/Moscow', '2014-10-25 23:00:00 UTC'::timestamptz); +SELECT timezone('Europe/Moscow', '2014-10-25 23:00:01 UTC'::timestamptz); +SELECT timezone('Europe/Moscow', '2014-10-26 02:00:01 UTC'::timestamptz); + +SELECT timezone('MSK', '2014-10-25 21:59:59 UTC'::timestamptz); +SELECT timezone('MSK', '2014-10-25 22:00:00 UTC'::timestamptz); +SELECT timezone('MSK', '2014-10-25 22:59:59 UTC'::timestamptz); +SELECT timezone('MSK', '2014-10-25 23:00:00 UTC'::timestamptz); +SELECT timezone('MSK', '2014-10-25 23:00:01 UTC'::timestamptz); +SELECT timezone('MSK', '2014-10-26 02:00:01 UTC'::timestamptz); + SELECT make_timestamptz(2014, 10, 26, 0, 0, 0, 'MSK'); SELECT make_timestamptz(2014, 10, 26, 1, 0, 0, 'MSK');