Skip to content

Commit

Permalink
* add timezone(zone, timestamptz) testcases
Browse files Browse the repository at this point in the history
Signed-off-by: chagelo <[email protected]>
  • Loading branch information
chagelo committed Nov 21, 2024
1 parent a7e4520 commit bc69f0b
Show file tree
Hide file tree
Showing 2 changed files with 223 additions and 0 deletions.
187 changes: 187 additions & 0 deletions src/tests/regress/data/expected/timestamptz.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------------
Expand Down
36 changes: 36 additions & 0 deletions src/tests/regress/data/sql/timestamptz.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit bc69f0b

Please sign in to comment.