← Back to team overview

touch-packages team mailing list archive

[Bug 1482504] Re: Putting and then getting dates in a document are altered by u1db

 

** Branch linked: lp:~uonedb-qt/u1db-qt/dateStrings

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to u1db-qt in Ubuntu.
https://bugs.launchpad.net/bugs/1482504

Title:
  Putting and then getting dates in a document are altered by u1db

Status in U1DB Qt/ QML:
  New
Status in u1db-qt package in Ubuntu:
  New

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","date":"2015-08-07T06:15:36.573Z"}
  (so, it offsetted correctly in UTC)

  console.log("Before save: " + JSON.stringify(tosave));
  db.putDoc(tosave, current.billId);
  var after = db.getDoc(current.billId.toString())
  console.log("After save: " + JSON.stringify(afterSave));

  log is:
  qml: Before save: {"title":"First element","date":"2015-08-07T06:15:36.573Z"}
  qml: After save: {"date":"2015-08-07T08:15:36","title":"First element"}
  -> Looking at the sqlite database, indeed, putDoc() saved "2015-08-07T08:15:36" and not "2015-08-07T06:15:36.573Z". And then, assigning that to a Date variable will reapply again the timezone offest, thinking the string is in UTC, and resulting in 10:15 instead of 08.15.

  -> 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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/u1db-qt/+bug/1482504/+subscriptions


References