Putting and then getting dates in a document are altered by u1db
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
U1DB Qt/ QML |
New
|
Undecided
|
Cris Dywan | ||
u1db-qt (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
When putting and getting a QML date in the u1db database, the resulting strings are stored differently, even if you don't do any type conversion.
The result is that the resulting date is shifted by the current timezone, rendering an incorrect date.
Small example:
qml: date object to save: "Fri Aug 7 08:15:36 2015 GMT+0200" (value chosen by the user in a datetime picker: 08:15)
This value is jsonified in var current = {"title":"First element"
(so, it offsetted correctly in UTC)
console.log("Before save: " + JSON.stringify(
db.putDoc(tosave, current.billId);
var after = db.getDoc(
console.log("After save: " + JSON.stringify(
log is:
qml: Before save: {"title":"First element"
qml: After save: {"date"
-> Looking at the sqlite database, indeed, putDoc() saved "2015-08-
-> Note that the date element has been altered and isn't returned in the same format The date should be returned unalterned. Then it's up to the user to save the timezone independently if they want.
Related branches
- PS Jenkins bot: Needs Fixing (continuous-integration)
- U1DB Qt developers: Pending requested
-
Diff: 26 lines (+16/-0)1 file modifiedtests/tst_database.qml (+16/-0)
tags: | added: devexp |
description: | updated |
description: | updated |
Changed in u1db-qt: | |
assignee: | nobody → Christian Dywan (kalikiana) |
current workaround is to cheat on the saved date in database, meaning, removing again the timezone to the date object to shift it to UTC (it will print as "<time in UTC> + (timezone)" which is untrue, so only do that for the database object)
Example, just before putDoc: "date"] .getTime( ) + tosave[ "date"] .getTimezoneOff set() * 60000)
tosave["date"] = new Date(tosave[