-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Date tranformations #5899
Comments
MySql is a tricky one. It doesn't allow us to store timezones in the database so you only get to store something that looks like: Waterline will take the iso strings you send and You can specify a timezone for the mysql connection to use in your connections config:
If you need exact times for calculations I would suggest storing integer epoch times which you can use independent of any mysql timezone trickery. Other databases like Postgres allow the timezone to be stored in the date so it's not an issue when you |
Sorry, I should have mentioned that I am already using timezone:'UTC'. So there still should be no transformations. Also the newly tranlsated date by new Date() "Fri Jun 20 2014 20:00:00 GMT-0500 (Central Daylight Time)" should translate back to "2014-06-20T01:00:00.000Z" because it has the offset and although MySQL does not store timezone info, it will translate an timestring with an offset just fine. In this instance its as if sails is sending I have already made the switch to using |
@particlebanana I think this is a problem with the That said, would you entertain the ability to pass in an override for |
Notice the 3 objects below. Dates are getting modified when I try to push them to sails. The original date objects send to the server are in ISO string as you can see below. Somewhere before the update my dates are being re-calculated for timezone offset?
I'm on sails.js 0.10.5, waterline 0.10.10, sails-mysql 0.10.5
Original Data sent to server
{"shiftStart": "2014-06-20T01:00:00.000Z",
"shiftEnd": "2014-06-20T13:00:00.000Z"}
These is the result of sending 'values' to the console.log on my model callbacks.
beforeValidate
{ shiftStart: Fri Jun 20 2014 20:00:00 GMT-0500 (Central Daylight Time),
shiftEnd: Sat Jun 21 2014 08:00:00 GMT-0500 (Central Daylight Time)}
beforeUpdate
{ shiftStart: Fri Jun 20 2014 20:00:00 GMT-0500 (Central Daylight Time),
shiftEnd: Sat Jun 21 2014 08:00:00 GMT-0500 (Central Daylight Time)}
afterUpdate
{ shiftStart: Fri Jun 20 2014 15:00:00 GMT-0500 (Central Daylight Time),
shiftEnd: Sat Jun 21 2014 03:00:00 GMT-0500 (Central Daylight Time)}
The text was updated successfully, but these errors were encountered: