-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #514 from benighted/parse-date-as-local
Parse date type as local time
- Loading branch information
Showing
2 changed files
with
5 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2716f95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why local time? Our dates are stored UTC.
2716f95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe PostgreSQL itself recommends you return dates in the client timezone unless the timezone is specified (as it is in
TIMESTAMPTZ
data type).Good news is I haven't released this code yet, and since it's a breaking change it wont happen until I bump the major version number to
3
. For the v3.0 release I'm going to try to spin the type system out into its own module and better document how implement your own type parsers so if you'd rather have your dates considered UTC all the time you can easily override that behavior.2716f95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is basically that javascript parses a timestamp as local time unless it is in valid ISO-8601 format, ie "YYYY-MM-DDTHH:MM:SS", but postgres uses a format like "YYYY-MM-DD HH:MM:SS" (note the space instead of letter "T") which is not valid ISO-8601. To standardize the behavior, it was decided to also parse the Date type as local time as well, even though it is technically valid ISO-8601 without the time portion. This was discussed in issue #510 if you are still curious.