Question about the `date` type
See original GitHub issueThe Postgres date
data type has no information about timezone. That wouldn’t make any sense. However, the dateParser in node-postgres defaults to Greenwich timezone due to the way it’s instantiating the object.
According to this MDN article, when creating a new Date, the constructor uses the Date.parse
which, if passed a string without a timezone, will default to the systems timezone. This is not the behavior I’m seeing in the node.
Consider the following on my system in GMT-0600
new Date('2014-01-24').getDate() // => 23
new Date('2014-01-24 00:00:00').getDate() // => 24
new Date( 2014, 0, 24 ).getDate() // => 24
It’s my feeling that when the data type is date
then we should use one of the latter two methods so that it actually defaults to system timezone. The first method is being employed by node-postgres right now:
https://github.com/brianc/node-postgres/blob/master/lib/types/textParsers.js#L17
Thoughts?
Issue Analytics
- State:
- Created 10 years ago
- Comments:11 (10 by maintainers)
Top GitHub Comments
Right. Not a PG problem but a node-pg problem. My fix:
This issue appears to be resolved and able to be closed.