void QTimeZone::CalculateOffset(const QDateTime &dateTime, QTimeSpan &offset, bool &bIsNegative) const { // DST started to be applied in 1916 static const QDateTime FIRST_DATETIME_WITH_DST(1916, 1, 1); // Boost can only process dates prior to the year 10.000 static const QDateTime MAXIMUM_DATETIME_WITH_DST = QDateTime(10000, 1, 1) - QTimeSpan(1); QE_ASSERT(dateTime != QDateTime::GetUndefinedDate(), "The input date is undefined"); QTimeSpan dstOffset(0); offset = m_timeZoneOffset; if(m_bHasDstOffset && dateTime >= FIRST_DATETIME_WITH_DST && dateTime < MAXIMUM_DATETIME_WITH_DST) { QDateTime startDateTime = m_dstInformation.GetStartInYear(dateTime.GetYear()); QDateTime endDateTime = m_dstInformation.GetEndInYear(dateTime.GetYear()); if(dateTime >= startDateTime && dateTime < endDateTime) { if(!m_bTzOffsetIsNegative && !m_dstInformation.IsOffsetNegative()) { // Both offsets are positive, they are summed offset += m_dstInformation.GetOffset(); bIsNegative = false; } else if(m_bTzOffsetIsNegative && m_dstInformation.IsOffsetNegative()) { // Both are negative, they are summed offset += m_dstInformation.GetOffset(); bIsNegative = true; } else if(m_timeZoneOffset >= m_dstInformation.GetOffset()) { // Time zone offset is bigger or equals the DST offset, the result is the difference offset -= m_dstInformation.GetOffset(); bIsNegative = m_bTzOffsetIsNegative; } else { // Time zone offset is smaller than the DST offset, the result is the difference offset = m_dstInformation.GetOffset() - offset; bIsNegative = m_dstInformation.IsOffsetNegative(); } } else { bIsNegative = m_bTzOffsetIsNegative; } } else { bIsNegative = m_bTzOffsetIsNegative; } }