diff --git a/mythtv/libs/libmyth/util.cpp b/mythtv/libs/libmyth/util.cpp
index c5358b0..84fb8eb 100644
|
a
|
b
|
QDateTime myth_dt_from_string(const QString &dtstr)
|
| 84 | 84 | return QDateTime::fromString(dtstr, Qt::ISODate); |
| 85 | 85 | } |
| 86 | 86 | |
| | 87 | // Note: this function calculates the offset from UTC "right now". That offset |
| | 88 | // may not be valid a moment later, since daylight savings time might start or |
| | 89 | // end during that moment. Thus it's not valid to use this in calculations of |
| | 90 | // future events, like program guide data |
| 87 | 91 | int calc_utc_offset(void) |
| 88 | 92 | { |
| | 93 | |
| 89 | 94 | QDateTime loc = QDateTime::currentDateTime(); |
| 90 | | QDateTime utc = QDateTime::currentDateTime().toUTC(); |
| | 95 | QDateTime utc = loc; // make an exact copy so elapsed time doesn't factor in |
| | 96 | utc.setTimeSpec(Qt::UTC); // keeping same clock time, change only the time zone |
| 91 | 97 | |
| 92 | | int utc_offset = MythSecsTo(utc, loc); |
| | 98 | int utc_offset = MythSecsTo(loc, utc); |
| 93 | 99 | |
| 94 | 100 | // clamp to nearest minute if within 10 seconds |
| 95 | 101 | int off = utc_offset % 60; |
| … |
… |
bool checkTimeZone(const QStringList &master_settings)
|
| 529 | 535 | */ |
| 530 | 536 | int MythSecsTo(const QDateTime &from, const QDateTime &to) |
| 531 | 537 | { |
| 532 | | return (from.time().secsTo(to.time()) + |
| 533 | | from.date().daysTo(to.date()) * 60 * 60 * 24); |
| | 538 | return (from.secsTo(to)); |
| 534 | 539 | } |
| 535 | 540 | |
| 536 | 541 | /** \fn MythUTCToLocal(const QDateTime&) |
| … |
… |
int MythSecsTo(const QDateTime &from, const QDateTime &to)
|
| 538 | 543 | */ |
| 539 | 544 | QDateTime MythUTCToLocal(const QDateTime &utc) |
| 540 | 545 | { |
| 541 | | QDateTime local = QDateTime(QDate(1970, 1, 1)); |
| | 546 | QDateTime local = QDateTime(QDate(1970, 1, 1),QTime(0,0,0),Qt::UTC); |
| 542 | 547 | |
| 543 | 548 | int timesecs = MythSecsTo(local, utc); |
| 544 | 549 | QDateTime localdt; |