From bd78f57463c381203099d7939c9d37cba0341713 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Mon, 9 Jan 2017 13:45:03 -0800 Subject: [PATCH] Apple: always use the system time zone instead of the default time zone This corrects an issue converting dates and times to strings which would use the "default" time zone (CFTimeZoneCopyDefault) in contrast to the rest of Qt which uses the system time zone in such contexts. [ChangeLog][QtCore][QLocale] Qt functions now always use the system time zone on Apple platforms, the same that low-level C APIs like localtime() does. Previously, converting dates and times to strings would use the "default" time zone (which is almost always the same as the "system" time zone but could be changed with the Apple API). Change-Id: I2942c3c1c8aa01a0130f1b7280371a72bdb01b1c Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale_mac.mm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm index 80b37bec1f..c5519bfabf 100644 --- a/src/corelib/tools/qlocale_mac.mm +++ b/src/corelib/tools/qlocale_mac.mm @@ -123,8 +123,7 @@ static QString macDayName(int day, bool short_format) static QString macDateToString(const QDate &date, bool short_format) { - const QTimeZone tz = QTimeZone::fromCFTimeZone(QCFType(CFTimeZoneCopyDefault())); - QCFType myDate = QDateTime(date, QTime(), tz).toCFDate(); + QCFType myDate = QDateTime(date, QTime()).toCFDate(); QCFType mylocale = CFLocaleCopyCurrent(); CFDateFormatterStyle style = short_format ? kCFDateFormatterShortStyle : kCFDateFormatterLongStyle; QCFType myFormatter @@ -136,8 +135,7 @@ static QString macDateToString(const QDate &date, bool short_format) static QString macTimeToString(const QTime &time, bool short_format) { - const QTimeZone tz = QTimeZone::fromCFTimeZone(QCFType(CFTimeZoneCopyDefault())); - QCFType myDate = QDateTime(QDate::currentDate(), time, tz).toCFDate(); + QCFType myDate = QDateTime(QDate::currentDate(), time).toCFDate(); QCFType mylocale = CFLocaleCopyCurrent(); CFDateFormatterStyle style = short_format ? kCFDateFormatterShortStyle : kCFDateFormatterLongStyle; QCFType myFormatter = CFDateFormatterCreate(kCFAllocatorDefault,