mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Fix UTC to Localtime Error in GcRideFile
The GcRideFile stores the ride start datetime in UTC, on write the datetime is correctly converted to UTC. This patch fixes the GcRideFile reader to convert in the oposite direction. Currently the code reads the UTC date as a local format date - as a result the convert to localtime call does nothing.
This commit is contained in:
committed by
Sean Rhea
parent
e0f6cf23e6
commit
ccc2f1f0ff
@@ -54,8 +54,14 @@ GcFileReader::openRideFile(QFile &file, QStringList &errors) const
|
||||
QString value = attr.attribute("value");
|
||||
if (key == "Device type")
|
||||
rideFile->setDeviceType(value);
|
||||
if (key == "Start time")
|
||||
rideFile->setStartTime(QDateTime::fromString(value, DATETIME_FORMAT).toLocalTime());
|
||||
if (key == "Start time") {
|
||||
// by default QDateTime is localtime - the source however is UTC
|
||||
QDateTime aslocal = QDateTime::fromString(value, DATETIME_FORMAT);
|
||||
// construct in UTC so we can honour the conversion to localtime
|
||||
QDateTime asUTC = QDateTime(aslocal.date(), aslocal.time(), Qt::UTC);
|
||||
// now set in localtime
|
||||
rideFile->setStartTime(asUTC.toLocalTime());
|
||||
}
|
||||
}
|
||||
|
||||
QVector<double> intervalStops; // used to set the interval number for each point
|
||||
|
||||
Reference in New Issue
Block a user