node-sql-query icon indicating copy to clipboard operation
node-sql-query copied to clipboard

Store all dates as UTC for SQLite

Open apoco opened this issue 11 years ago • 3 comments

Dates are stored in SQLite as Unix timestamps. Dates are represented in JavaScript as Unix timestamps. Thus, there need not be any sort of conversions. Client-side timezones are irrelevant; they should only affect the client-side display of dates. The existing code is incorrect because it's storing timezone-offset dates as UTC dates (with the "Z" suffix).

This change simplifies the type conversion; a Date is stored as an ISO-8601 date string, which is understood by both JavaScript's Date constructor and SQLite.

apoco avatar Oct 31 '14 01:10 apoco

Looks good, I'll just have to run this against ORM

dxg avatar Nov 13 '14 23:11 dxg

Great. I have some changes locally that work in conjunction with this, but I hesitated creating a PR since it won't pass without this package's updates. Would it be helpful for me to put a PR together, or is this pretty straightforward?

Another option that occurred to me is maybe having a different data type for this, like isodate; that way, if there is anyone that is using the current behavior would not be affected by the change. What are your thoughts? I'm not in a big rush because I went with just using strings for now.

apoco avatar Nov 15 '14 02:11 apoco

I've continued discussion in dresende/node-orm2#568 Feel free to open the pull request and write a comment about why the tests fail inside.

dxg avatar Nov 16 '14 04:11 dxg