X-Git-Url: https://www.flypig.org.uk/git/?p=harbour-pedalo.git;a=blobdiff_plain;f=qml%2Fpages%2FAddJourney.qml;h=a9124ae1acad638c6c98e203acf3135dbfa8e150;hp=9d7a4369e805174fcff100c0d253da40e3ab5764;hb=badbb9139e0e5b3bc114ae7c150e6d9ab5183566;hpb=371dcf3335b355f8d421352a394161dc6d9b9f24 diff --git a/qml/pages/AddJourney.qml b/qml/pages/AddJourney.qml index 9d7a436..a9124ae 100644 --- a/qml/pages/AddJourney.qml +++ b/qml/pages/AddJourney.qml @@ -79,8 +79,9 @@ Dialog { onClicked: { var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: time.getHours(), minute: time.getMinutes()}) dialog.accepted.connect(function() { - time = new Date(0, 0, 0, dialog.hour, dialog.minute) - duration = ((endTime.time.getHours() - start.getHours()) * 60) + (endTime.time.getMinutes() - start.getMinutes()) * 60 + // We have to hack around the fact that % in Javascript is 'remainder' and not 'mod' (hence will happpily return negative numbers) + duration = ((((((dialog.hour - start.getHours()) * 60) + (dialog.minute - start.getMinutes())) * 60) % 86400) + 86400) % 86400 + // Updating the duration will automatically trigger the end time to be udpated }) } onTimeChanged: { @@ -94,7 +95,7 @@ Dialog { value: Qt.formatTime(new Date(0, 0, 0, 0, parseInt(duration / 60)), 'hh:mm') width: parent.width onClicked: { - var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: parseInt(duration / (60 * 60)), minute: parseInt(duration / 60) % 60}) + var dialog = pageStack.push("DurationEditDialog.qml", { hour: parseInt(duration / (60 * 60)), minute: parseInt(duration / 60) % 60}) dialog.accepted.connect(function() { duration = ((dialog.hour * 60) + dialog.minute) * 60 })