#18 Updates timestamps to improve consistency between PostgREST and realtime

This commit is contained in:
Paul Copplestone
2020-02-04 18:56:13 +08:00
parent d3e1f1fb96
commit 035b2d4304
2 changed files with 16 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@supabase/supabase-js",
"version": "0.1.16",
"version": "0.1.17",
"description": "Supabase Realtime API",
"main": "./lib/index.js",
"scripts": {

View File

@@ -106,7 +106,7 @@ export const convertChangeData = (columns, records, options = {}) => {
case 'time':
return noop(stringValue) // To allow users to cast it based on Timezone
case 'timestamp':
return noop(stringValue) // To allow users to cast it based on Timezone
return toTimestampString(stringValue) // Format to be consistent with PostgREST
case 'timestamptz':
return noop(stringValue) // To allow users to cast it based on Timezone
case 'timetz':
@@ -160,4 +160,18 @@ export const convertChangeData = (columns, records, options = {}) => {
}
const toJson = stringValue => {
return JSON.parse(stringValue)
}
/**
* Fixes timestamp to be ISO-8601. Swaps the space between the date and time for a 'T'
* See https://github.com/supabase/supabase/issues/18
* @returns {string}
*
* @example
* toTimestampString('2019-09-10 00:00:00')
* //=>
* '2019-09-10T00:00:00'
*/
const toTimestampString = stringValue => {
return stringValue.replace(' ', 'T')
}