QTimeZone: make UTC offset range available for other code to reuse
When QDateTimeParser learns to parse zones, it'll need to know the valid range of offsets. Change-Id: I44cd88a140ebaf6a2b98b0f9a1be0cbc7a35bae4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
748d87f28f
commit
536b918eca
@ -338,12 +338,9 @@ QTimeZone::QTimeZone(const QByteArray &ianaId)
|
||||
*/
|
||||
|
||||
QTimeZone::QTimeZone(int offsetSeconds)
|
||||
: d((offsetSeconds >= MinUtcOffsetSecs && offsetSeconds <= MaxUtcOffsetSecs)
|
||||
? new QUtcTimeZonePrivate(offsetSeconds) : nullptr)
|
||||
{
|
||||
// offsetSeconds must fall between -14:00 and +14:00 hours
|
||||
if (offsetSeconds >= -50400 && offsetSeconds <= 50400)
|
||||
d = new QUtcTimeZonePrivate(offsetSeconds);
|
||||
else
|
||||
d = 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -59,6 +59,14 @@ class QTimeZonePrivate;
|
||||
class Q_CORE_EXPORT QTimeZone
|
||||
{
|
||||
public:
|
||||
// Sane UTC offsets range from -14 to +14 hours:
|
||||
enum {
|
||||
// No known zone > 12 hrs West of Greenwich (Baker Island, USA)
|
||||
MinUtcOffsetSecs = -14 * 3600,
|
||||
// No known zone > 14 hrs East of Greenwich (Kiritimati, Christmas Island, Kiribati)
|
||||
MaxUtcOffsetSecs = +14 * 3600
|
||||
};
|
||||
|
||||
enum TimeType {
|
||||
StandardTime = 0,
|
||||
DaylightTime = 1,
|
||||
|
@ -258,6 +258,8 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
|
||||
brackets the correct time and at most one DST transition.
|
||||
*/
|
||||
const qint64 sixteenHoursInMSecs(16 * 3600 * 1000);
|
||||
Q_STATIC_ASSERT(-sixteenHoursInMSecs / 1000 < QTimeZone::MinUtcOffsetSecs
|
||||
&& sixteenHoursInMSecs / 1000 > QTimeZone::MaxUtcOffsetSecs);
|
||||
/*
|
||||
Offsets are Local - UTC, positive to the east of Greenwich, negative to
|
||||
the west; DST offset always exceeds standard offset, when DST applies.
|
||||
|
Loading…
Reference in New Issue
Block a user