From b0bc8af718ca367bca27d4c9ed8ebf0db1a45c0d Mon Sep 17 00:00:00 2001
From: reznet <reznet@gmail.com>
Date: Tue, 11 Aug 2015 13:12:43 -0500
Subject: [PATCH] Use UTC when converting to QDateTime for graph axis

QDateTime::fromMSecsSinceEpoch returns a QDateTime in the local time zone, but the ms input was created in UTC.  This causes the day part to sometimes display off by a day on the graph x axis.  This appears to be caused by a breaking change in QT 5.  Previously, fromMSecsSinceEpoch returned a QDateTime in UTC, but in QT 5, it returns the date time in the local time zone.
---
 sleepyhead/Graphs/gXAxis.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sleepyhead/Graphs/gXAxis.cpp b/sleepyhead/Graphs/gXAxis.cpp
index d68af0e5..93f3741a 100644
--- a/sleepyhead/Graphs/gXAxis.cpp
+++ b/sleepyhead/Graphs/gXAxis.cpp
@@ -397,8 +397,10 @@ void gXAxisDay::paint(QPainter &painter, gGraph &graph, const QRegion &region)
     minx = graph.min_x;
     maxx = graph.max_x;
 
-    QDateTime date2 = QDateTime::fromMSecsSinceEpoch(minx);
-    QDateTime enddate2 = QDateTime::fromMSecsSinceEpoch(maxx);
+    QDateTime date2 = QDateTime::fromMSecsSinceEpoch(minx, Qt::UTC);
+    QDateTime enddate2 = QDateTime::fromMSecsSinceEpoch(maxx, Qt::UTC);
+
+    qInfo() << "Drawing date axis from " << date2 << " to " << enddate2;
 
     QDate date = date2.date();
 //    QDate enddate = enddate2.date();