void LocalDateTime::determineTzd(bool adjust) { if (adjust) { std::time_t epochTime = _dateTime.timestamp().epochTime(); #if defined(_WIN32) || defined(POCO_NO_POSIX_TSF) #if defined(_WIN32_WCE) std::tm* broken = wceex_localtime(&epochTime); #else std::tm* broken = std::localtime(&epochTime); #endif if (!broken) throw Poco::SystemException("cannot get local time"); _tzd = (Timezone::utcOffset() + ((broken->tm_isdst == 1) ? 3600 : 0)); #else std::tm broken; #if defined(POCO_VXWORKS) if (localtime_r(&epochTime, &broken) != OK) throw Poco::SystemException("cannot get local time"); #else if (!localtime_r(&epochTime, &broken)) throw Poco::SystemException("cannot get local time"); #endif _tzd = (Timezone::utcOffset() + ((broken.tm_isdst == 1) ? 3600 : 0)); #endif adjustForTzd(); } else { int dst; dstOffset(dst); _tzd = (Timezone::utcOffset() + dst); } }
void PatchReader::checkSpatialTypeSize( splash::DataCollector* const dc, const uint32_t availableRanks, const int32_t id, const std::string particlePatchPathComponent ) const { // will later read into 1D buffer from first position on splash::Dimensions dstBuffer(availableRanks, 1, 1); splash::Dimensions dstOffset(0, 0, 0); // sizeRead will be set splash::Dimensions sizeRead(0, 0, 0); splash::CollectionType* colType = dc->readMeta( id, particlePatchPathComponent.c_str(), dstBuffer, dstOffset, sizeRead ); // check if the 1D list of patches has the right length assert( sizeRead[0] == availableRanks ); // currently only support uint64_t types to spare type conversation assert( typeid(*colType) == typeid(splash::ColTypeUInt64) ); // free collections __delete( colType ); }
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; } }
void PatchReader::readPatchAttribute( splash::DataCollector* const dc, const uint32_t availableRanks, const int32_t id, const std::string particlePatchPathComponent, uint64_t* const dest ) const { // will later read into 1D buffer from first position on splash::Dimensions dstBuffer(availableRanks, 1, 1); splash::Dimensions dstOffset(0, 0, 0); // sizeRead will be set splash::Dimensions sizeRead(0, 0, 0); // check if types, number of patches and names are supported checkSpatialTypeSize( dc, availableRanks, id, particlePatchPathComponent.c_str() ); // read actual offset and extent data of particle patch component dc->read( id, particlePatchPathComponent.c_str(), sizeRead, (void*)dest ); }