diff options
author | Jake Petroules <jake.petroules@qt.io> | 2017-01-09 13:45:03 -0800 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2017-01-24 19:40:45 +0000 |
commit | bd78f57463c381203099d7939c9d37cba0341713 (patch) | |
tree | 59c5fd7e16d84fca068573c1edcf5c20af6fb246 /src/corelib | |
parent | c1cece8e546a138609c974be94588ba4e72c6fb1 (diff) |
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 <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qlocale_mac.mm | 6 |
1 files 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<CFTimeZoneRef>(CFTimeZoneCopyDefault())); - QCFType<CFDateRef> myDate = QDateTime(date, QTime(), tz).toCFDate(); + QCFType<CFDateRef> myDate = QDateTime(date, QTime()).toCFDate(); QCFType<CFLocaleRef> mylocale = CFLocaleCopyCurrent(); CFDateFormatterStyle style = short_format ? kCFDateFormatterShortStyle : kCFDateFormatterLongStyle; QCFType<CFDateFormatterRef> 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<CFTimeZoneRef>(CFTimeZoneCopyDefault())); - QCFType<CFDateRef> myDate = QDateTime(QDate::currentDate(), time, tz).toCFDate(); + QCFType<CFDateRef> myDate = QDateTime(QDate::currentDate(), time).toCFDate(); QCFType<CFLocaleRef> mylocale = CFLocaleCopyCurrent(); CFDateFormatterStyle style = short_format ? kCFDateFormatterShortStyle : kCFDateFormatterLongStyle; QCFType<CFDateFormatterRef> myFormatter = CFDateFormatterCreate(kCFAllocatorDefault, |