Permalink
Browse files

Simplify calc_utc_offset().

  • Loading branch information...
daniel-kristjansson committed May 5, 2012
1 parent fcfd8e2 commit c6f64109ae6ff9e89006b0aacd2a3bfc70087368
Showing with 3 additions and 15 deletions.
  1. +3 −15 mythtv/libs/libmythbase/mythmiscutil.cpp
@@ -201,21 +201,9 @@ QString toString(const QDate &date, uint format)
int calc_utc_offset(void)
{
QDateTime loc = QDateTime::currentDateTime();
- QDateTime utc = QDateTime::currentDateTime().toUTC();
-
- int utc_offset = (utc.time().secsTo(loc.time()) +
- utc.date().daysTo(loc.date()) * 60 * 60 * 24);
-
- // clamp to nearest minute if within 10 seconds
- int off = utc_offset % 60;
- if (abs(off) < 10)
- utc_offset -= off;
- if (off < -50 && off > -60)
- utc_offset -= 60 + off;
- if (off > +50 && off < +60)
- utc_offset += 60 - off;
-
- return utc_offset;
+ QDateTime utc = loc.toUTC();
+ loc = QDateTime(loc.date(), loc.time(), Qt::UTC);
+ return utc.secsTo(loc);
}
static bool compare_zone_files(QFileInfo first_file_info,

0 comments on commit c6f6410

Please sign in to comment.