Open feneks opened 8 years ago
I'll take a look, thanks (the whole time/date thing needs to be rewritten)
In my experience, the time stamps only get lost when they are set to <10:00h (i.e. 9:59:00 will get deleted, 10:00:00 stays). As a workaround, one can set all affected times to at least 10:00:00.
thanks
I've been digging a bit more - it must be related to this bit in AddValue.qml (around line 172):
dialogTime.accepted.connect(function()
{
console.log("You chose: " + dialogTime.timeText)
var tt = dialogTime.timeText + ":00"
if (dialogTime.hour < 10)
tt = "0" + tt
updateDateTime(nowDate, tt)
})
I can see from the console log that "updateDateTime" reports "newtime 009:00:00" if I set the time to 09:00 - note the extra "0" at the start. From what I can see, the "0" gets added by the lines I pasted above. The console.log line above ("You choose"...) prints "09:00", so it looks like dialogTime.timeText already adds that "0". I have no experience with QML or Jolla programming (I know just enough about coding to be dangerous...), so I have no idea whether this is related to the version of Sailfish and/or the locale settings. The better approach would probably be to check the string length rather than the numerical value - if I knew how, I'd try it right now... :-}
Right, search engines are such a nice invention - didn't know that QML uses JavaScript... :-)
This seems to work:
dialogTime.accepted.connect(function()
{
console.log("You chose: " + dialogTime.timeText)
var tt = dialogTime.timeText + ":00"
console.log("Length: " + tt.length)
if (tt.length < 8)
tt = "0" + tt
updateDateTime(nowDate, tt)
})
(the second console log was just to check what is going on...)
Ok, that patch is not complete - it fixed the problem when actually changing the time with the time-widget(? - that round thingy to enter the time), but when doing "Show Raw Data -> Edit a value with a time stamp < 10:00", the time stamp still vanishes to start with. That is fixed by adding another length check in Component.onCompleted:
Component.onCompleted:
{
/* Check are we adding new, or editing existing one */
if (nowDate == "value" && nowTime == "value" && value == "value")
{
var tmp = new Date()
updateDateTime(Qt.formatDateTime(tmp, "yyyy-MM-dd"), Qt.formatDateTime(tmp, "hh:mm:ss"))
pageTitle = qsTr("Add")
}
else
{
if (nowTime == "")
nowTime = "00:00:00"
if (nowTime.length < 8)
nowTime = "0" + nowTime
console.log("nowdate " + nowDate + " nowtime " + nowTime)
updateDateTime(nowDate, nowTime)
valueField.text = (value == "value") ? "" : value
annotationField.text = (value == "value") ? "" : annotation
pageTitle = (value == "value") ? qsTr("Add") : qsTr("Edit")
}
}
Now, I haven't checked whether the original length check is now actually obsolete, as I lack the time to dig into this code sufficiently, so this is most likely not the most elegant solution. I still hope it is of some use to you (and it certainly lets me use valuelogger without that issue until you get round to address this properly).
When you add values and alter time there is no value for time. Date works as expected. Saving values without altering time works too.
I don't know java-script but I recognized these:
qml/pages/AddValue.qml:line30-31
qml/pages/AddValue.qml:line172-173
if clause without '{' and '}' ?
qml/pages/ShowData.qml:line64