You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently I get my dates (defined with datatype DATE) back as f.e. "2021-03-02T23:00:00.000Z" while pgadmin gives 2021-03-03. So I get the wrong date back (and a timestamp was added).
You can find the same issue in node-postgres brianc/node-postgres#818 where someone suggests a workaround in the end (that I just tested, it works). brianc/node-postgres#818 , see a paste of the snippet below. Can this be fixed in deno-postgres? My proposal would be to change decodeDate in decode.ts to simply
function decodeDate(dateStr: string): Date {
return new Date(dateStr + 'T00:00:00Z');
}
of course that works for year 0001 too. ;-) For null values in the postgress date the function decodeDate is not executed.
/* Node postgres date fix /
var Moment = require('moment');
var parseDate = function parseDate(val) {
return val === null ? null : Moment(val).format('YYYY-MM-DD')
};
var types = pg.types;
var DATATYPE_DATE = 1082;
types.setTypeParser(DATATYPE_DATE, function(val) {
return val === null ? null : parseDate(val)
});
/ Node postgres date fix - end */
The text was updated successfully, but these errors were encountered:
…ateStr + 'T00:00:00Z')
/* text of issue denodrivers#181 copied */
Currently I get my dates (defined with datatype DATE) back as f.e. "2021-03-02T23:00:00.000Z" while pgadmin gives 2021-03-03. So I get the wrong date back (and a timestamp was added).
You can find the same issue in node-postgres brianc/node-postgres#818 where someone suggests a workaround in the end (that I just tested, it works). brianc/node-postgres#818 , see a paste of the snippet below. Can this be fixed in deno-postgres? My proposal would be to change decodeDate in decode.ts to simply
function decodeDate(dateStr: string): Date {
return new Date(dateStr + 'T00:00:00Z');
}
of course that works for year 0001 too. ;-) For null values in the postgress date the function decodeDate is not executed.
/* Node postgres date fix /
var Moment = require('moment');
var parseDate = function parseDate(val) {
return val === null ? null : Moment(val).format('YYYY-MM-DD')
};
var types = pg.types;
var DATATYPE_DATE = 1082;
types.setTypeParser(DATATYPE_DATE, function(val) {
return val === null ? null : parseDate(val)
});
/ Node postgres date fix - end */
Currently I get my dates (defined with datatype DATE) back as f.e. "2021-03-02T23:00:00.000Z" while pgadmin gives 2021-03-03. So I get the wrong date back (and a timestamp was added).
You can find the same issue in node-postgres brianc/node-postgres#818 where someone suggests a workaround in the end (that I just tested, it works). brianc/node-postgres#818 , see a paste of the snippet below. Can this be fixed in deno-postgres? My proposal would be to change decodeDate in decode.ts to simply
of course that works for year 0001 too. ;-) For null values in the postgress date the function decodeDate is not executed.
The text was updated successfully, but these errors were encountered: