Prefer "daylight-saving time" and "DST" over "daylight time".
The first two are the "proper" terms; the last is a colloquialism. Also amended "daylight savings" (which summons to mind a hybrid of "daylight robbery" and "bargain-basket savings"). Improved related wording in many of the places amended. Task-number: QTBUG-49308 Change-Id: I726f18a344b2fe37f765a14684d1447c8b7ab00c Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
This commit is contained in:
parent
708424c305
commit
4890c75d0d
@ -103,7 +103,7 @@ struct tm {
|
||||
int tm_year; /* years since 1900 */
|
||||
int tm_wday; /* days since Sunday - [0,6] */
|
||||
int tm_yday; /* days since January 1 - [0,365] */
|
||||
int tm_isdst; /* daylight savings time flag */
|
||||
int tm_isdst; /* daylight-saving time flag */
|
||||
};
|
||||
#endif // _TM_DEFINED
|
||||
|
||||
|
@ -1383,7 +1383,7 @@ bool QDate::isLeapYear(int y)
|
||||
|
||||
QTime uses the 24-hour clock format; it has no concept of AM/PM.
|
||||
Unlike QDateTime, QTime knows nothing about time zones or
|
||||
daylight savings time (DST).
|
||||
daylight-saving time (DST).
|
||||
|
||||
A QTime object is typically created either by giving the number
|
||||
of hours, minutes, seconds, and milliseconds explicitly, or by
|
||||
@ -2059,7 +2059,7 @@ void QTime::start()
|
||||
|
||||
\warning If the system's clock setting has been changed since the
|
||||
last time start() or restart() was called, the result is
|
||||
undefined. This can happen when daylight savings time is turned on
|
||||
undefined. This can happen when daylight-saving time is turned on
|
||||
or off.
|
||||
|
||||
\sa start(), elapsed(), currentTime()
|
||||
@ -2087,7 +2087,7 @@ int QTime::restart()
|
||||
|
||||
\warning If the system's clock setting has been changed since the
|
||||
last time start() or restart() was called, the result is
|
||||
undefined. This can happen when daylight savings time is turned on
|
||||
undefined. This can happen when daylight-saving time is turned on
|
||||
or off.
|
||||
|
||||
\sa start(), restart()
|
||||
@ -2301,7 +2301,7 @@ static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStat
|
||||
}
|
||||
|
||||
// Calls the platform variant of localtime for the given msecs, and updates
|
||||
// the date, time, and daylight status with the returned values.
|
||||
// the date, time, and DST status with the returned values.
|
||||
static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localTime,
|
||||
QDateTimePrivate::DaylightStatus *daylightStatus)
|
||||
{
|
||||
@ -2417,7 +2417,7 @@ static bool epochMSecsToLocalTime(qint64 msecs, QDate *localDate, QTime *localTi
|
||||
*daylightStatus = QDateTimePrivate::StandardTime;
|
||||
return true;
|
||||
} else if (msecs > (qint64(TIME_T_MAX) * 1000)) {
|
||||
// Docs state any LocalTime after 2037-12-31 *will* have any Daylight Time applied
|
||||
// Docs state any LocalTime after 2037-12-31 *will* have any DST applied
|
||||
// but this may fall outside the supported time_t range, so need to fake it.
|
||||
// Use existing method to fake the conversion, but this is deeply flawed as it may
|
||||
// apply the conversion from the wrong day number, e.g. if rule is last Sunday of month
|
||||
@ -2442,7 +2442,7 @@ static bool epochMSecsToLocalTime(qint64 msecs, QDate *localDate, QTime *localTi
|
||||
}
|
||||
|
||||
// Convert a LocalTime expressed in local msecs encoding and the corresponding
|
||||
// daylight status into a UTC epoch msecs. Optionally populate the returned
|
||||
// DST status into a UTC epoch msecs. Optionally populate the returned
|
||||
// values from mktime for the adjusted local date and time.
|
||||
static qint64 localMSecsToEpochMSecs(qint64 localMsecs,
|
||||
QDateTimePrivate::DaylightStatus *daylightStatus,
|
||||
@ -2457,10 +2457,10 @@ static qint64 localMSecsToEpochMSecs(qint64 localMsecs,
|
||||
|
||||
if (localMsecs <= qint64(MSECS_PER_DAY)) {
|
||||
|
||||
// Docs state any LocalTime before 1970-01-01 will *not* have any Daylight Time applied
|
||||
// Docs state any LocalTime before 1970-01-01 will *not* have any DST applied
|
||||
|
||||
// First, if localMsecs is within +/- 1 day of minimum time_t try mktime in case it does
|
||||
// fall after minimum and needs proper daylight conversion
|
||||
// fall after minimum and needs proper DST conversion
|
||||
if (localMsecs >= -qint64(MSECS_PER_DAY)) {
|
||||
bool valid;
|
||||
qint64 utcMsecs = qt_mktime(&dt, &tm, daylightStatus, abbreviation, &valid);
|
||||
@ -2488,11 +2488,11 @@ static qint64 localMSecsToEpochMSecs(qint64 localMsecs,
|
||||
|
||||
} else if (localMsecs >= msecsMax - MSECS_PER_DAY) {
|
||||
|
||||
// Docs state any LocalTime after 2037-12-31 *will* have any Daylight Time applied
|
||||
// Docs state any LocalTime after 2037-12-31 *will* have any DST applied
|
||||
// but this may fall outside the supported time_t range, so need to fake it.
|
||||
|
||||
// First, if localMsecs is within +/- 1 day of maximum time_t try mktime in case it does
|
||||
// fall before maximum and can use proper daylight conversion
|
||||
// fall before maximum and can use proper DST conversion
|
||||
if (localMsecs <= msecsMax + MSECS_PER_DAY) {
|
||||
bool valid;
|
||||
qint64 utcMsecs = qt_mktime(&dt, &tm, daylightStatus, abbreviation, &valid);
|
||||
@ -2662,7 +2662,7 @@ void QDateTimePrivate::setDaylightStatus(QDateTimePrivate::DaylightStatus status
|
||||
}
|
||||
}
|
||||
|
||||
// Get the Daylight Status if LocalTime set via msecs
|
||||
// Get the DST Status if LocalTime set via msecs
|
||||
QDateTimePrivate::DaylightStatus QDateTimePrivate::daylightStatus() const
|
||||
{
|
||||
if ((m_status & SetToDaylightTime) == SetToDaylightTime)
|
||||
@ -2746,7 +2746,7 @@ void QDateTimePrivate::refreshDateTime()
|
||||
#endif // QT_BOOTSTRAPPED
|
||||
|
||||
// We have a valid date and time and a Qt::LocalTime or Qt::TimeZone that needs calculating
|
||||
// LocalTime and TimeZone might fall into "missing" DaylightTime transition hour
|
||||
// LocalTime and TimeZone might fall into a "missing" DST transition hour
|
||||
// Calling toEpochMSecs will adjust the returned date/time if it does
|
||||
QDate testDate;
|
||||
QTime testTime;
|
||||
@ -2776,8 +2776,8 @@ qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone
|
||||
{
|
||||
// Get the effective data from QTimeZone
|
||||
QTimeZonePrivate::Data data = zone.d->dataForLocalTime(zoneMSecs);
|
||||
// Docs state any LocalTime before 1970-01-01 will *not* have any Daylight Time applied
|
||||
// but all times afterwards will have Daylight Time applied.
|
||||
// Docs state any LocalTime before 1970-01-01 will *not* have any DST applied
|
||||
// but all affected times afterwards will have DST applied.
|
||||
if (data.atMSecsSinceEpoch >= 0) {
|
||||
msecsToTime(data.atMSecsSinceEpoch + (data.offsetFromUtc * 1000), localDate, localTime);
|
||||
return data.atMSecsSinceEpoch;
|
||||
@ -2836,7 +2836,7 @@ qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone
|
||||
QDateTime expressed as local time; use toUTC() to convert it to
|
||||
UTC. You can also use timeSpec() to find out if a QDateTime
|
||||
object stores a UTC time or a local time. Operations such as
|
||||
addSecs() and secsTo() are aware of daylight saving time (DST).
|
||||
addSecs() and secsTo() are aware of daylight-saving time (DST).
|
||||
|
||||
\note QDateTime does not account for leap seconds.
|
||||
|
||||
@ -2866,7 +2866,7 @@ qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone
|
||||
correctly or not up-to-date, QDateTime will give wrong results as
|
||||
well.
|
||||
|
||||
\section2 Daylight Savings Time (DST)
|
||||
\section2 Daylight-Saving Time (DST)
|
||||
|
||||
QDateTime takes into account the system's time zone information
|
||||
when dealing with DST. On modern Unix systems, this means it
|
||||
@ -2884,7 +2884,7 @@ qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone
|
||||
time zone before 1970, even if the system's time zone database
|
||||
supports that information.
|
||||
|
||||
QDateTime takes into consideration the Standard Time to Daylight Time
|
||||
QDateTime takes into consideration the Standard Time to Daylight-Saving Time
|
||||
transition. For example if the transition is at 2am and the clock goes
|
||||
forward to 3am, then there is a "missing" hour from 02:00:00 to 02:59:59.999
|
||||
which QDateTime considers to be invalid. Any date maths performed
|
||||
@ -2896,7 +2896,7 @@ qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone
|
||||
to define a QDateTime relative to UTC at a fixed offset of a given number
|
||||
of seconds from UTC. For example, an offset of +3600 seconds is one hour
|
||||
ahead of UTC and is usually written in ISO standard notation as
|
||||
"UTC+01:00". Daylight Savings Time never applies with this TimeSpec.
|
||||
"UTC+01:00". Daylight-Saving Time never applies with this TimeSpec.
|
||||
|
||||
There is no explicit size restriction to the offset seconds, but there is
|
||||
an implicit limit imposed when using the toString() and fromString()
|
||||
@ -2908,8 +2908,8 @@ qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone
|
||||
|
||||
A Qt::TimeSpec of Qt::TimeZone is also supported in conjunction with the
|
||||
QTimeZone class. This allows you to define a datetime in a named time zone
|
||||
adhering to a consistent set of daylight savings transition rules. For
|
||||
example a time zone of "Europe/Berlin" will apply the daylight savings
|
||||
adhering to a consistent set of daylight-saving transition rules. For
|
||||
example a time zone of "Europe/Berlin" will apply the daylight-saving
|
||||
rules as used in Germany since 1970. Note that the transition rules
|
||||
applied depend on the platform support. See the QTimeZone documentation
|
||||
for more details.
|
||||
@ -3051,7 +3051,7 @@ bool QDateTime::isNull() const
|
||||
the current Qt::TimeSpec, otherwise returns \c false.
|
||||
|
||||
If the timeSpec() is Qt::LocalTime or Qt::TimeZone then the date and time are
|
||||
checked to see if they fall in the Standard Time to Daylight Time transition
|
||||
checked to see if they fall in the Standard Time to Daylight-Saving Time transition
|
||||
hour, i.e. if the transition is at 2am and the clock goes forward to 3am
|
||||
then the time from 02:00:00 to 02:59:59.999 is considered to be invalid.
|
||||
|
||||
@ -3142,10 +3142,10 @@ QTimeZone QDateTime::timeZone() const
|
||||
If the timeSpec() is Qt::OffsetFromUTC this will be the value originally set.
|
||||
|
||||
If the timeSpec() is Qt::TimeZone this will be the offset effective in the
|
||||
Time Zone including any Daylight Saving Offset.
|
||||
Time Zone including any Daylight-Saving Offset.
|
||||
|
||||
If the timeSpec() is Qt::LocalTime this will be the difference between the
|
||||
Local Time and UTC including any Daylight Saving Offset.
|
||||
Local Time and UTC including any Daylight-Saving Offset.
|
||||
|
||||
If the timeSpec() is Qt::UTC this will be 0.
|
||||
|
||||
@ -3202,7 +3202,7 @@ QString QDateTime::timeZoneAbbreviation() const
|
||||
/*!
|
||||
\since 5.2
|
||||
|
||||
Returns if this datetime falls in Daylight Savings Time.
|
||||
Returns if this datetime falls in Daylight-Saving Time.
|
||||
|
||||
If the Qt::TimeSpec is not Qt::LocalTime or Qt::TimeZone then will always
|
||||
return false.
|
||||
@ -3415,8 +3415,8 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs)
|
||||
break;
|
||||
case Qt::TimeZone:
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
// Docs state any LocalTime before 1970-01-01 will *not* have any Daylight Time applied
|
||||
// but all times afterwards will have Daylight Time applied.
|
||||
// Docs state any LocalTime before 1970-01-01 will *not* have any DST applied
|
||||
// but all affected times afterwards will have DST applied.
|
||||
if (msecs >= 0)
|
||||
d->m_offsetFromUtc = d->m_timeZone.d->offsetFromUtc(msecs);
|
||||
else
|
||||
@ -3658,7 +3658,7 @@ QString QDateTime::toString(const QString& format) const
|
||||
negative).
|
||||
|
||||
If the timeSpec() is Qt::LocalTime and the resulting
|
||||
date and time fall in the Standard Time to Daylight Time transition
|
||||
date and time fall in the Standard Time to Daylight-Saving Time transition
|
||||
hour then the result will be adjusted accordingly, i.e. if the transition
|
||||
is at 2am and the clock goes forward to 3am and the result falls between
|
||||
2am and 3am then the result will be adjusted to fall after 3am.
|
||||
@ -3693,7 +3693,7 @@ QDateTime QDateTime::addDays(qint64 ndays) const
|
||||
is negative).
|
||||
|
||||
If the timeSpec() is Qt::LocalTime and the resulting
|
||||
date and time fall in the Standard Time to Daylight Time transition
|
||||
date and time fall in the Standard Time to Daylight-Saving Time transition
|
||||
hour then the result will be adjusted accordingly, i.e. if the transition
|
||||
is at 2am and the clock goes forward to 3am and the result falls between
|
||||
2am and 3am then the result will be adjusted to fall after 3am.
|
||||
@ -3728,7 +3728,7 @@ QDateTime QDateTime::addMonths(int nmonths) const
|
||||
negative).
|
||||
|
||||
If the timeSpec() is Qt::LocalTime and the resulting
|
||||
date and time fall in the Standard Time to Daylight Time transition
|
||||
date and time fall in the Standard Time to Daylight-Saving Time transition
|
||||
hour then the result will be adjusted accordingly, i.e. if the transition
|
||||
is at 2am and the clock goes forward to 3am and the result falls between
|
||||
2am and 3am then the result will be adjusted to fall after 3am.
|
||||
@ -3788,7 +3788,7 @@ QDateTime QDateTime::addMSecs(qint64 msecs) const
|
||||
|
||||
QDateTime dt(*this);
|
||||
if (d->m_spec == Qt::LocalTime || d->m_spec == Qt::TimeZone)
|
||||
// Convert to real UTC first in case crosses daylight transition
|
||||
// Convert to real UTC first in case crosses DST transition
|
||||
dt.setMSecsSinceEpoch(d->toMSecsSinceEpoch() + msecs);
|
||||
else
|
||||
// No need to convert, just add on
|
||||
@ -3823,8 +3823,8 @@ qint64 QDateTime::daysTo(const QDateTime &other) const
|
||||
the value returned is negative.
|
||||
|
||||
Before performing the comparison, the two datetimes are converted
|
||||
to Qt::UTC to ensure that the result is correct if one of the two
|
||||
datetimes has daylight saving time (DST) and the other doesn't.
|
||||
to Qt::UTC to ensure that the result is correct if daylight-saving
|
||||
(DST) applies to one of the two datetimes but not the other.
|
||||
|
||||
Returns 0 if either datetime is invalid.
|
||||
|
||||
@ -3845,8 +3845,8 @@ qint64 QDateTime::secsTo(const QDateTime &other) const
|
||||
the value returned is negative.
|
||||
|
||||
Before performing the comparison, the two datetimes are converted
|
||||
to Qt::UTC to ensure that the result is correct if one of the two
|
||||
datetimes has daylight saving time (DST) and the other doesn't.
|
||||
to Qt::UTC to ensure that the result is correct if daylight-saving
|
||||
(DST) applies to one of the two datetimes and but not the other.
|
||||
|
||||
Returns 0 if either datetime is invalid.
|
||||
|
||||
|
@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE
|
||||
platforms that support it (see QElapsedTimer::isMonotonic()). This has
|
||||
the added benefit that QElapsedTimer is immune to time adjustments, such
|
||||
as the user correcting the time. Also unlike QTime, QElapsedTimer is
|
||||
immune to changes in the timezone settings, such as daylight saving
|
||||
immune to changes in the timezone settings, such as daylight-saving
|
||||
periods.
|
||||
|
||||
On the other hand, this means QElapsedTimer values can only be compared
|
||||
|
@ -199,14 +199,15 @@ Q_GLOBAL_STATIC(QTimeZoneSingleton, global_tz);
|
||||
The difference between UTC and the local time in a time zone is expressed
|
||||
as an offset in seconds from UTC, i.e. the number of seconds to add to UTC
|
||||
to obtain the local time. The total offset is comprised of two component
|
||||
parts, the standard time offset and the daylight time offset. The standard
|
||||
time offset is the number of seconds to add to UTC to obtain standard time
|
||||
in the time zone. The daylight time offset is the number of seconds to add
|
||||
to the standard time offset to obtain daylight time in the time zone.
|
||||
parts, the standard time offset and the daylight-saving time offset. The
|
||||
standard time offset is the number of seconds to add to UTC to obtain
|
||||
standard time in the time zone. The daylight-saving time offset is the
|
||||
number of seconds to add to the standard time offset to obtain
|
||||
daylight-saving time (abbreviated DST and sometimes called "daylight time"
|
||||
or "summer time") in the time zone.
|
||||
|
||||
Note that the standard and daylight offsets for a time zone may change over
|
||||
time as countries have changed daylight time laws or even their standard
|
||||
time offset.
|
||||
Note that the standard and DST offsets for a time zone may change over time
|
||||
as countries have changed DST laws or even their standard time offset.
|
||||
|
||||
\section2 License
|
||||
|
||||
@ -241,21 +242,20 @@ Q_GLOBAL_STATIC(QTimeZoneSingleton, global_tz);
|
||||
\enum QTimeZone::TimeType
|
||||
|
||||
The type of time zone time, for example when requesting the name. In time
|
||||
zones that do not apply daylight time, all three values may return the
|
||||
same result.
|
||||
zones that do not apply DST, all three values may return the same result.
|
||||
|
||||
\value StandardTime
|
||||
The standard time in a time zone, i.e. when Daylight Savings is not
|
||||
The standard time in a time zone, i.e. when Daylight-Saving is not
|
||||
in effect.
|
||||
For example when formatting a display name this will show something
|
||||
like "Pacific Standard Time".
|
||||
\value DaylightTime
|
||||
A time when Daylight Savings is in effect.
|
||||
A time when Daylight-Saving is in effect.
|
||||
For example when formatting a display name this will show something
|
||||
like "Pacific daylight time".
|
||||
like "Pacific daylight-saving time".
|
||||
\value GenericTime
|
||||
A time which is not specifically Standard or Daylight time, either
|
||||
an unknown time or a neutral form.
|
||||
A time which is not specifically Standard or Daylight-Saving time,
|
||||
either an unknown time or a neutral form.
|
||||
For example when formatting a display name this will show something
|
||||
like "Pacific Time".
|
||||
*/
|
||||
@ -286,11 +286,11 @@ Q_GLOBAL_STATIC(QTimeZoneSingleton, global_tz);
|
||||
\li OffsetData::atUtc The datetime of the offset data in UTC time.
|
||||
\li OffsetData::offsetFromUtc The total offset from UTC in effect at the datetime.
|
||||
\li OffsetData::standardTimeOffset The standard time offset component of the total offset.
|
||||
\li OffsetData::daylightTimeOffset The daylight time offset component of the total offset.
|
||||
\li OffsetData::daylightTimeOffset The DST offset component of the total offset.
|
||||
\li OffsetData::abbreviation The abbreviation in effect at the datetime.
|
||||
\endlist
|
||||
|
||||
For example, for time zone "Europe/Berlin" the OffsetDate in standard and daylight time might be:
|
||||
For example, for time zone "Europe/Berlin" the OffsetDate in standard and DST might be:
|
||||
|
||||
\list
|
||||
\li atUtc = QDateTime(QDate(2013, 1, 1), QTime(0, 0, 0), Qt::UTC)
|
||||
@ -531,8 +531,7 @@ QString QTimeZone::comment() const
|
||||
If the \a locale is not provided then the application default locale will
|
||||
be used.
|
||||
|
||||
The display name may change depending on daylight time or historical
|
||||
events.
|
||||
The display name may change depending on DST or historical events.
|
||||
|
||||
\sa abbreviation()
|
||||
*/
|
||||
@ -572,8 +571,7 @@ QString QTimeZone::displayName(TimeType timeType, NameType nameType,
|
||||
|
||||
/*!
|
||||
Returns the time zone abbreviation at the given \a atDateTime. The
|
||||
abbreviation may change depending on daylight time or even
|
||||
historical events.
|
||||
abbreviation may change depending on DST or even historical events.
|
||||
|
||||
Note that the abbreviation is not guaranteed to be unique to this time zone
|
||||
and should not be used in place of the ID or display name.
|
||||
@ -592,13 +590,13 @@ QString QTimeZone::abbreviation(const QDateTime &atDateTime) const
|
||||
/*!
|
||||
Returns the total effective offset at the given \a atDateTime, i.e. the
|
||||
number of seconds to add to UTC to obtain the local time. This includes
|
||||
any daylight time offset that may be in effect, i.e. it is the sum of
|
||||
any DST offset that may be in effect, i.e. it is the sum of
|
||||
standardTimeOffset() and daylightTimeOffset() for the given datetime.
|
||||
|
||||
For example, for the time zone "Europe/Berlin" the standard time offset is
|
||||
+3600 seconds and the daylight time offset is +3600 seconds. During standard
|
||||
time offsetFromUtc() will return +3600 (UTC+01:00), and during daylight time
|
||||
it will return +7200 (UTC+02:00).
|
||||
+3600 seconds and the DST offset is +3600 seconds. During standard time
|
||||
offsetFromUtc() will return +3600 (UTC+01:00), and during DST it will
|
||||
return +7200 (UTC+02:00).
|
||||
|
||||
\sa standardTimeOffset(), daylightTimeOffset()
|
||||
*/
|
||||
@ -614,11 +612,11 @@ int QTimeZone::offsetFromUtc(const QDateTime &atDateTime) const
|
||||
/*!
|
||||
Returns the standard time offset at the given \a atDateTime, i.e. the
|
||||
number of seconds to add to UTC to obtain the local Standard Time. This
|
||||
excludes any daylight time offset that may be in effect.
|
||||
excludes any DST offset that may be in effect.
|
||||
|
||||
For example, for the time zone "Europe/Berlin" the standard time offset is
|
||||
+3600 seconds. During both standard and daylight time offsetFromUtc() will
|
||||
return +3600 (UTC+01:00).
|
||||
+3600 seconds. During both standard and DST offsetFromUtc() will return
|
||||
+3600 (UTC+01:00).
|
||||
|
||||
\sa offsetFromUtc(), daylightTimeOffset()
|
||||
*/
|
||||
@ -632,13 +630,13 @@ int QTimeZone::standardTimeOffset(const QDateTime &atDateTime) const
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the daylight time offset at the given \a atDateTime, i.e. the
|
||||
number of seconds to add to the standard time offset to obtain the local
|
||||
daylight time.
|
||||
Returns the daylight-saving time offset at the given \a atDateTime,
|
||||
i.e. the number of seconds to add to the standard time offset to obtain the
|
||||
local daylight-saving time.
|
||||
|
||||
For example, for the time zone "Europe/Berlin" the daylight time offset
|
||||
is +3600 seconds. During standard time daylightTimeOffset() will return
|
||||
0, and during daylight time it will return +3600.
|
||||
For example, for the time zone "Europe/Berlin" the DST offset is +3600
|
||||
seconds. During standard time daylightTimeOffset() will return 0, and when
|
||||
daylight-saving is in effect it will return +3600.
|
||||
|
||||
\sa offsetFromUtc(), standardTimeOffset()
|
||||
*/
|
||||
@ -652,7 +650,7 @@ int QTimeZone::daylightTimeOffset(const QDateTime &atDateTime) const
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if the time zone has observed daylight time at any time.
|
||||
Returns \c true if the time zone has practiced daylight-saving at any time.
|
||||
|
||||
\sa isDaylightTime(), daylightTimeOffset()
|
||||
*/
|
||||
@ -666,7 +664,7 @@ bool QTimeZone::hasDaylightTime() const
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if the given \a atDateTime is in daylight time.
|
||||
Returns \c true if daylight-saving was in effect at the given \a atDateTime.
|
||||
|
||||
\sa hasDaylightTime(), daylightTimeOffset()
|
||||
*/
|
||||
|
@ -246,8 +246,8 @@ QTimeZonePrivate::Data QTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const
|
||||
QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs) const
|
||||
{
|
||||
if (!hasDaylightTime() ||!hasTransitions()) {
|
||||
// No daylight time means same offset for all local msecs
|
||||
// Having daylight time but no transitions means we can't calculate, so use nearest
|
||||
// No DST means same offset for all local msecs
|
||||
// Having DST but no transitions means we can't calculate, so use nearest
|
||||
return data(forLocalMSecs - (standardTimeOffset(forLocalMSecs) * 1000));
|
||||
}
|
||||
|
||||
@ -276,16 +276,16 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs)
|
||||
}
|
||||
|
||||
if (tran.daylightTimeOffset == 0) {
|
||||
// If tran is in StandardTime, then need to check if falls close either daylight transition
|
||||
// If tran is in StandardTime, then need to check if falls close to either DST transition.
|
||||
// If it does, then it may need adjusting for missing hour or for second occurrence
|
||||
qint64 diffPrevTran = forLocalMSecs
|
||||
- (tran.atMSecsSinceEpoch + (tran.offsetFromUtc * 1000));
|
||||
qint64 diffNextTran = nextTran.atMSecsSinceEpoch + (nextTran.offsetFromUtc * 1000)
|
||||
- forLocalMSecs;
|
||||
if (diffPrevTran >= 0 && diffPrevTran < MSECS_TRAN_WINDOW) {
|
||||
// If tran picked is for standard time check if changed from daylight in last 6 hours,
|
||||
// If tran picked is for standard time check if changed from DST in last 6 hours,
|
||||
// as the local msecs may be ambiguous and represent two valid utc msecs.
|
||||
// If in last 6 hours then get prev tran and if diff falls within the daylight offset
|
||||
// If in last 6 hours then get prev tran and if diff falls within the DST offset
|
||||
// then use the prev tran as we default to the FirstOccurrence
|
||||
// TODO Check if faster to just always get prev tran, or if faster using 6 hour check.
|
||||
Data dstTran = previousTransition(tran.atMSecsSinceEpoch);
|
||||
|
@ -150,7 +150,7 @@ int QAndroidTimeZonePrivate::daylightTimeOffset(qint64 atMSecsSinceEpoch) const
|
||||
bool QAndroidTimeZonePrivate::hasDaylightTime() const
|
||||
{
|
||||
if ( androidTimeZone.isValid() )
|
||||
/* note: the Java function only tests for future daylight transtions, not past */
|
||||
/* note: the Java function only tests for future DST transtions, not past */
|
||||
return androidTimeZone.callMethod<jboolean>("useDaylightTime" );
|
||||
else
|
||||
return false;
|
||||
@ -210,34 +210,34 @@ QTimeZonePrivate::Data QAndroidTimeZonePrivate::dataForLocalTime(qint64 forLocal
|
||||
} else {
|
||||
qint64 UTCepochMSecs;
|
||||
|
||||
// compare the UTC time with standard offset against normal daylight offset of one hour
|
||||
// compare the UTC time with standard offset against normal DST offset of one hour
|
||||
qint64 standardUTCMSecs(forLocalMSecs - (standardTimeOffset(forLocalMSecs) * 1000));
|
||||
qint64 daylightUTCMsecs;
|
||||
|
||||
// Check if daylight time does apply,
|
||||
// checking also for daylight time boundaries
|
||||
// Check if daylight-saving time applies,
|
||||
// checking also for DST boundaries
|
||||
if (isDaylightTime(standardUTCMSecs)) {
|
||||
// If daylight does apply, then standardUTCMSecs will be an hour or so ahead of the real epoch time
|
||||
// If DST does apply, then standardUTCMSecs will be an hour or so ahead of the real epoch time
|
||||
// so check that time
|
||||
daylightUTCMsecs = standardUTCMSecs - daylightTimeOffset(standardUTCMSecs)*1000;
|
||||
if (isDaylightTime(daylightUTCMsecs)) {
|
||||
// daylight time confirmed
|
||||
// DST confirmed
|
||||
UTCepochMSecs = daylightUTCMsecs;
|
||||
} else {
|
||||
// daylight time has just finished
|
||||
// DST has just finished
|
||||
UTCepochMSecs = standardUTCMSecs;
|
||||
}
|
||||
} else {
|
||||
// Standard time indicated, but check for a false negative.
|
||||
// Would a standard one-hour daylight offset indicate daylight time?
|
||||
// Would a standard one-hour DST offset indicate DST?
|
||||
daylightUTCMsecs = standardUTCMSecs - 3600000; // 3600000 MSECS_PER_HOUR
|
||||
if (isDaylightTime(daylightUTCMsecs)) {
|
||||
// daylight time may have just started,
|
||||
// but double check against timezone's own daylight offset
|
||||
// DST may have just started,
|
||||
// but double check against timezone's own DST offset
|
||||
// (don't necessarily assume a one-hour offset)
|
||||
daylightUTCMsecs = standardUTCMSecs - daylightTimeOffset(daylightUTCMsecs)*1000;
|
||||
if (isDaylightTime(daylightUTCMsecs)) {
|
||||
// daylight time confirmed
|
||||
// DST confirmed
|
||||
UTCepochMSecs = daylightUTCMsecs;
|
||||
} else {
|
||||
// false positive, apply standard time after all
|
||||
|
Loading…
x
Reference in New Issue
Block a user