Description
A Javascript Date
is always parsed in local timezone. A DATE column in Postgres or any other DB doesn't have any timezone associated with it, it is just a date. It begins and ends differently depending on where you are. Parsing this as a JS Date
that has timezone associated with it is a huge problem. Let's say your server is located in GMT+2 (Germany). You insert a date into your database, like 2016-08-26
. When you query that in Germany, you will get the Date
object Fri Aug 26 2016 00:00:00 GMT+0200
. But run toUTCString()
on it, and you get Thu, 25 Aug 2016 22:00:00 GMT
! The date is one day off. This imposes a huge problem for distributed applications.
TL;DR JavaScript objects are not suited to represent a DATE field, because they have a timezone and time associated, while a DATE has not.
postgres-date
should not be used to parse it and instead, the string should be returned (just like with a DECIMAL). Users can register their own type parser with their own DateOnly
object if they want.
This will be a breaking change and we would like to depend on this in Sequelize 4.