X-Git-Url: https://www.flypig.org.uk/git/?p=harbour-pedalo.git;a=blobdiff_plain;f=src%2Fjourney.cpp;h=775ece7fd3922b26da7e8ee2dccfd113afa5c999;hp=af13ec851c2d6eda4ab89af15424cfd5c110a028;hb=e917baa52e7157c7c41424527c3881c22ff65588;hpb=0108947ead4cc9e0ff23fee82db2fb1fd7cb2dad diff --git a/src/journey.cpp b/src/journey.cpp index af13ec8..775ece7 100644 --- a/src/journey.cpp +++ b/src/journey.cpp @@ -21,6 +21,29 @@ quint64 Journey::getStart () const { return start; } +QDate Journey::getStartDate() const { + QDateTime date; + + date.setMSecsSinceEpoch(start); + return date.date(); +} + +QTime Journey::getStartTime() const { + QDateTime time; + + time.setMSecsSinceEpoch(start); + return time.time(); +} + +QTime Journey::getEndTime() const { + QDateTime time; + + time.setMSecsSinceEpoch(start); + time.addSecs(duration); + + return time.time(); +} + qint32 Journey::getDuration () const { return duration; } @@ -38,6 +61,35 @@ void Journey::setStart (const quint64 value) { start = value; } +void Journey::setStartDate (const QDate &value) { + QDateTime time; + + time.setMSecsSinceEpoch(start); + time.setDate(value); +} + +void Journey::setStartTime (const QTime &value) { + QDateTime time; + + time.setMSecsSinceEpoch(start); + time.setTime(value); +} + +void Journey::setEndTime(const QTime &value) { + qint64 difference; + QDateTime starttime; + QDateTime endtime; + + starttime.setMSecsSinceEpoch(start); + endtime = QDateTime(starttime); + endtime.setTime(value); + difference = starttime.secsTo(endtime); + if (difference < 0) { + difference %= 24 * 60 * 60; + } + duration = difference; +} + void Journey::setDuration (qint32 value) { duration = value; }