Merge pull request #169 from CartoDB/2202-DateToNumber-with-time-zones
Changes CDB_DateToNumber() to accept timestamps with time zones 2202
This commit is contained in:
commit
39e558f494
@ -13,3 +13,19 @@ RETURN output;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' STABLE STRICT;
|
||||
|
||||
-- Convert timestamp with time zone to double precision
|
||||
--
|
||||
CREATE OR REPLACE FUNCTION CDB_DateToNumber(input timestamp with time zone)
|
||||
RETURNS double precision AS $$
|
||||
DECLARE output double precision;
|
||||
BEGIN
|
||||
BEGIN
|
||||
SELECT extract (EPOCH FROM input) INTO output;
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
RETURN NULL;
|
||||
END;
|
||||
RETURN output;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' STABLE STRICT;
|
||||
|
2
test/CDB_DateToNumberTest.sql
Normal file
2
test/CDB_DateToNumberTest.sql
Normal file
@ -0,0 +1,2 @@
|
||||
SELECT * FROM CDB_DateToNumber('1999-01-08 00:00:00'::timestamp);
|
||||
SELECT * FROM CDB_DateToNumber('1999-01-08 00:00:00+05'::timestamp with time zone);
|
2
test/CDB_DateToNumberTest_expect
Normal file
2
test/CDB_DateToNumberTest_expect
Normal file
@ -0,0 +1,2 @@
|
||||
915753600
|
||||
915735600
|
Loading…
Reference in New Issue
Block a user