本文整理汇总了C++中QDateTime::GetYear方法的典型用法代码示例。如果您正苦于以下问题:C++ QDateTime::GetYear方法的具体用法?C++ QDateTime::GetYear怎么用?C++ QDateTime::GetYear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::GetYear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalculateOffset
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;
}
}