Skip to content

Question about the date type #510

Closed
Closed
@jrf0110

Description

@jrf0110

The 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions