Fix end_date of poll creation
Closed this issue · 2 comments
The timestamp passed from the frontend to the backend is a unix timestamp, i.e. in seconds. But JavaScript dates use milliseconds. When creating a poll, the end date sent by the frontend needs to be multiplied by 1000 to convert to milliseconds. Since it currently is not converted, all end dates are currently at some time on 1970-01-10
Alternatively—and I think this would be better—can we just store the start and end timestamps in the database as unix timestamps in seconds, instead of converting them to date strings?
The downside is that its not as user-friendly to just read the start and end dates when looking through the database, but the upside is no risk conversion errors (both when adding polls into the database and when reading from the database to see if a poll has ended)
Ahh good catch on this one.
Alternatively—and I think this would be better—can we just store the start and end timestamps in the database as unix timestamps in seconds, instead of converting them to date strings?
So, the database is storing them in whatever its native Date type is. Postico is probably displaying them as a timestamp string of some kind. It's probably Sequelize that is converting them to native JS Date()
objects. Should be an easy fix to convert it on the way in/out.