CREATE EXTENSION jdate; -- valid round trips SELECT '1403-01-01'::jdate; jdate ------------ 1403-01-01 (1 row) SELECT '1402-12-29'::jdate; -- last day of a common (29-day Esfand) year jdate ------------ 1402-12-29 (1 row) SELECT '1395-12-30'::jdate; -- last day of a leap (30-day Esfand) year jdate ------------ 1395-12-30 (1 row) SELECT '0001-01-01'::jdate; jdate ------------ 0001-01-01 (1 row) SELECT '-0061-01-01'::jdate; -- JALAALI_MIN_YEAR jdate ------------- -0061-01-01 (1 row) SELECT '3177-12-29'::jdate; -- JALAALI_MAX_YEAR, common year, 29-day Esfand jdate ------------ 3177-12-29 (1 row) -- infinity SELECT 'infinity'::jdate, '-infinity'::jdate; jdate | jdate ----------+----------- infinity | -infinity (1 row) SELECT 'INFINITY'::jdate, 'Infinity'::jdate; jdate | jdate ----------+---------- infinity | infinity (1 row) -- whitespace around the infinity words is accepted (like jtimestamp) SELECT ' infinity'::jdate, 'infinity '::jdate, ' -infinity '::jdate; jdate | jdate | jdate ----------+----------+----------- infinity | infinity | -infinity (1 row) SELECT E'\tinfinity\n'::jdate, E'\n-infinity\t'::jdate, E' \t INFINITY \n'::jdate; jdate | jdate | jdate ----------+-----------+---------- infinity | -infinity | infinity (1 row) -- but only around the words: nothing else gets looser \set VERBOSITY sqlstate SELECT '- infinity'::jdate; ERROR: 22007 SELECT 'infinity 1403-01-01'::jdate; ERROR: 22007 SELECT 'infinit'::jdate; ERROR: 22007 SELECT ' '::jdate; ERROR: 22007 \set VERBOSITY default -- invalid input: format errors SELECT 'garbage'::jdate; ERROR: invalid input syntax for type jdate: "garbage" LINE 1: SELECT 'garbage'::jdate; ^ SELECT '1403/01/01'::jdate; ERROR: invalid input syntax for type jdate: "1403/01/01" LINE 1: SELECT '1403/01/01'::jdate; ^ SELECT '1403-01-01 '::jdate; jdate ------------ 1403-01-01 (1 row) SELECT '1403-01-01extra'::jdate; ERROR: invalid input syntax for type jdate: "1403-01-01extra" LINE 1: SELECT '1403-01-01extra'::jdate; ^ -- invalid input: out-of-range values SELECT '1402-13-01'::jdate; -- bad month ERROR: date out of range for type jdate: "1402-13-01" LINE 1: SELECT '1402-13-01'::jdate; ^ SELECT '1402-00-01'::jdate; -- bad month ERROR: date out of range for type jdate: "1402-00-01" LINE 1: SELECT '1402-00-01'::jdate; ^ SELECT '1402-01-32'::jdate; -- bad day ERROR: date out of range for type jdate: "1402-01-32" LINE 1: SELECT '1402-01-32'::jdate; ^ SELECT '1394-12-30'::jdate; -- 1394 is common: no day 30 in Esfand ERROR: date out of range for type jdate: "1394-12-30" LINE 1: SELECT '1394-12-30'::jdate; ^ SELECT '-0062-01-01'::jdate; -- one below JALAALI_MIN_YEAR ERROR: date out of range for type jdate: "-0062-01-01" LINE 1: SELECT '-0062-01-01'::jdate; ^ SELECT '3178-01-01'::jdate; -- one above JALAALI_MAX_YEAR ERROR: date out of range for type jdate: "3178-01-01" LINE 1: SELECT '3178-01-01'::jdate; ^ -- integer overflow in a field is an error, never a wrapped value. sscanf's %d -- truncated these to 1403, 1, 1, 1403 and -1 respectively. \set VERBOSITY sqlstate SELECT '4294968699-01-01'::jdate; -- year 2^32 + 1403 ERROR: 22008 SELECT '1403-4294967297-01'::jdate; -- month 2^32 + 1 ERROR: 22008 SELECT '1403-01-4294967297'::jdate; -- day 2^32 + 1 ERROR: 22008 SELECT '-4294965893-01-01'::jdate; -- year -(2^32 - 1403) ERROR: 22008 SELECT '99999999999999999999-01-01'::jdate; -- far beyond int64 too ERROR: 22008 -- the int32 boundaries: the extremes that fit are out of the Jalali range, -- the ones that do not fit overflow; all are 22008 SELECT '2147483647-01-01'::jdate; -- INT32_MAX ERROR: 22008 SELECT '2147483648-01-01'::jdate; -- INT32_MAX + 1 ERROR: 22008 SELECT '-2147483648-01-01'::jdate; -- INT32_MIN ERROR: 22008 SELECT '-2147483649-01-01'::jdate; -- INT32_MIN - 1 ERROR: 22008 -- syntax errors stay 22007 SELECT ''::jdate; ERROR: 22007 SELECT '-'::jdate; ERROR: 22007 SELECT '1403'::jdate; ERROR: 22007 SELECT '1403-01'::jdate; ERROR: 22007 SELECT '1403-01-'::jdate; ERROR: 22007 SELECT '1403-x-01'::jdate; ERROR: 22007 SELECT '1403-01-01-01'::jdate; ERROR: 22007 \set VERBOSITY default SELECT '4294968699-01-01'::jdate; -- the message for an overflow ERROR: date out of range for type jdate: "4294968699-01-01" LINE 1: SELECT '4294968699-01-01'::jdate; ^ -- redundant leading zeros are not an overflow SELECT '0000000000000000000001403-01-01'::jdate; jdate ------------ 1403-01-01 (1 row) SELECT '1403-0000000000000000001-0000000000000000001'::jdate; jdate ------------ 1403-01-01 (1 row) -- the grammar is otherwise unchanged: leading and trailing whitespace, an -- optional '+' sign on any field, and whitespace around the dashes are -- accepted SELECT ' 1403-01-01'::jdate; jdate ------------ 1403-01-01 (1 row) SELECT '+1403-01-01'::jdate; jdate ------------ 1403-01-01 (1 row) SELECT '1403-+01-+01'::jdate; jdate ------------ 1403-01-01 (1 row) SELECT '1403 - 01 - 01'::jdate; jdate ------------ 1403-01-01 (1 row)