Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For postgres datatype DATE do not change that date (return new Date(d…
…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 */
- Loading branch information