File: tests-datetime.sql

package info (click to toggle)
icu-ext 1.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 336 kB
  • sloc: ansic: 2,701; sql: 764; makefile: 22; sh: 2
file content (40 lines) | stat: -rw-r--r-- 1,449 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* test date and time support */

\set format unaligned

set icu_ext.locale to 'en@calendar=gregorian';
set icu_ext.timestamptz_format to 'YYYY-MM-dd HH:mm:ss';
set timezone to 'Europe/Paris';

-- DST transition to summer time
select
 '2023-03-25 00:00:00'::timestamptz + '26.5 hours'::interval AS "core",
 '2023-03-25 00:00:00'::icu_timestamptz + '26.5 hours'::icu_interval AS "ext";

set icu_ext.locale to 'en@calendar=ethiopic';
set icu_ext.date_format to '{short}';

-- Use an explicit format for icu_timestamptz instead of {short},
-- since {short} had varied across ICU versions:
-- before ICU v72, the separator between hour and AM/PM designator
-- is an ASCII space, whereas since v72 it is NARROW NO-BREAK SPACE (U+202F)
--set icu_ext.timestamptz_format to '{short}';
set icu_ext.timestamptz_format to 'M/d/y G, hh:mm a';

-- 13-month year with 5 days in the last month
select '1/13/2016 ERA1'::icu_date + icu_interval '12 months' as d1,
  '1/13/2016 ERA1'::icu_date + icu_interval '13 months' as d2,
  '1/13/2016 ERA1'::icu_date + icu_interval '1 year' as d3;

select '13/5/2016 ERA1'::icu_date + 1;

set icu_ext.locale to 'en@calendar=gregorian';

select icu_parse_date('17/10/2023', 'dd/MM/yyyy');

select icu_parse_datetime('17/10/2023', 'dd/MM/yyyy');

select icu_parse_datetime('17/10/2023 12:02:40.653', 'dd/MM/yyyy HH:mm:ss.S');

set timezone to 'GMT';
select icu_parse_datetime('17/10/2023 12:02:40.653', 'dd/MM/yyyy HH:mm:ss.S');