Revision 7396
Added by Aaron Marcuse-Kubitza about 12 years ago
schemas/functions.sql | ||
---|---|---|
84 | 84 |
|
85 | 85 |
|
86 | 86 |
-- |
87 |
-- Name: _fix_date(date, date); Type: FUNCTION; Schema: functions; Owner: - |
|
88 |
-- |
|
89 |
|
|
90 |
CREATE FUNCTION _fix_date(value date DEFAULT NULL::date, threshold date DEFAULT NULL::date) RETURNS date |
|
91 |
LANGUAGE sql IMMUTABLE |
|
92 |
AS $_$ |
|
93 |
-- Fix dates after threshold date |
|
94 |
-- This fixes e.g. 2-digit years before 1970 misinterpreted as 20xx |
|
95 |
SELECT (CASE WHEN $1 > COALESCE($2, now()) THEN ($1 - '100 years'::interval)::date ELSE $1 END) |
|
96 |
$_$; |
|
97 |
|
|
98 |
|
|
99 |
-- |
|
87 | 100 |
-- Name: _if(boolean, anyelement, anyelement); Type: FUNCTION; Schema: functions; Owner: - |
88 | 101 |
-- |
89 | 102 |
|
Also available in: Unified diff
schemas/functions.sql: Added _fix_date()