-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix handling of timestamp fields without timezone #237
Conversation
Can you make a test for this issue? |
http://www.postgresql.org/docs/8.0/static/datatype-datetime.html This says they are assumed to be in the timezone of the writer: This says they are assumed to be in the timezone of the reader: I think it makes sense and the rationale is: in absence of a specified timezone we'll always assume times are local. |
The problem with the current implementation is that the way dates are stored in the database differs from the way they are read from there. When you create a new Date(0) object, write it to a TIMESTAMP WITHOUT TIMEZONE field and then read it again, you will receive a new Date(-3600000) object if your computer is set to timezone +01:00. If I understand you correctly, you propose to change prepareValue() in utils.js instead of the text parser? |
Why do you receive a different date than you insert ? Can you verify why where that value changes ? |
As far as I know, JSON.stringify() returns the date as UTC in ISO format. |
On Mon, Jan 14, 2013 at 07:29:46AM -0800, cdauth wrote:
Oh, I got it. Ok. Then I guess it should be some subsequent code changing it |
Hm, I guess if prepareValue() returned the date in the local timezone instead of UTC, things would be fine. If I understand the docu correctly, on a field without timezone, postgres would just ignore the timezone. |
On Mon, Jan 14, 2013 at 07:35:19AM -0800, cdauth wrote:
Uhm, you're right:
As long as we can get that kind of representation.. |
Issue #225 caused such dates to be read, but not stored in local time.
Commit b7fd9a5 fixes issue #225 but breaks the handling of timestamp fields that do not contain a timezone. The values returned by Postgres are always UTC, but the text parser assumes them to be in the timezone of the Node VM.