void msToGregorianDateTime(double ms, bool outputIsUTC, GregorianDateTime& tm) { // input is UTC double dstOff = 0.0; const double utcOff = getUTCOffset(); if (!outputIsUTC) { // convert to local time dstOff = getDSTOffset(ms, utcOff); ms += dstOff + utcOff; } const int year = msToYear(ms); tm.second = msToSeconds(ms); tm.minute = msToMinutes(ms); tm.hour = msToHours(ms); tm.weekDay = msToWeekDay(ms); tm.yearDay = dayInYear(ms, year); tm.monthDay = dayInMonthFromDayInYear(tm.yearDay, isLeapYear(year)); tm.month = monthFromDayInYear(tm.yearDay, isLeapYear(year)); tm.year = year - 1900; tm.isDST = dstOff != 0.0; tm.utcOffset = outputIsUTC ? 0 : static_cast<long>((dstOff + utcOff) / msPerSecond); tm.timeZone = NULL; }
// input is UTC void msToGregorianDateTime(VM& vm, double ms, WTF::TimeType outputTimeType, GregorianDateTime& tm) { LocalTimeOffset localTime; if (outputTimeType == WTF::LocalTime) { localTime = localTimeOffset(vm, ms); ms += localTime.offset; } const int year = msToYear(ms); tm.setSecond(msToSeconds(ms)); tm.setMinute(msToMinutes(ms)); tm.setHour(msToHours(ms)); tm.setWeekDay(msToWeekDay(ms)); tm.setYearDay(dayInYear(ms, year)); tm.setMonthDay(dayInMonthFromDayInYear(tm.yearDay(), isLeapYear(year))); tm.setMonth(monthFromDayInYear(tm.yearDay(), isLeapYear(year))); tm.setYear(year); tm.setIsDST(localTime.isDST); tm.setUtcOffset(localTime.offset / WTF::msPerSecond); }
// input is UTC void msToGregorianDateTime(ExecState* exec, double ms, bool outputIsUTC, GregorianDateTime& tm) { LocalTimeOffset localTime(false, 0); if (!outputIsUTC) { localTime = localTimeOffset(exec, ms); ms += localTime.offset; } const int year = msToYear(ms); tm.second = msToSeconds(ms); tm.minute = msToMinutes(ms); tm.hour = msToHours(ms); tm.weekDay = msToWeekDay(ms); tm.yearDay = dayInYear(ms, year); tm.monthDay = dayInMonthFromDayInYear(tm.yearDay, isLeapYear(year)); tm.month = monthFromDayInYear(tm.yearDay, isLeapYear(year)); tm.year = year - 1900; tm.isDST = localTime.isDST; tm.utcOffset = localTime.offset / WTF::msPerSecond; tm.timeZone = NULL; }
// input is UTC void msToGregorianDateTime(ExecState* exec, double ms, bool outputIsUTC, GregorianDateTime& tm) { double dstOff = 0.0; double utcOff = 0.0; if (!outputIsUTC) { utcOff = getUTCOffset(exec); dstOff = getDSTOffset(exec, ms, utcOff); ms += dstOff + utcOff; } const int year = msToYear(ms); tm.setSecond(msToSeconds(ms)); tm.setMinute(msToMinutes(ms)); tm.setHour(msToHours(ms)); tm.setWeekDay(msToWeekDay(ms)); tm.setYearDay(dayInYear(ms, year)); tm.setMonthDay(dayInMonthFromDayInYear(tm.yearDay(), isLeapYear(year))); tm.setMonth(monthFromDayInYear(tm.yearDay(), isLeapYear(year))); tm.setYear(year); tm.setIsDST(dstOff != 0.0); tm.setUtcOffset(static_cast<long>((dstOff + utcOff) / WTF::msPerSecond)); }
void TimerBase::setNextFireTime(double newTime) { ASSERT(canAccessThreadLocalDataForThread(m_thread)); ASSERT(!m_wasDeleted); if (m_unalignedNextFireTime != newTime) m_unalignedNextFireTime = newTime; // Accessing thread global data is slow. Cache the heap pointer. if (!m_cachedThreadGlobalTimerHeap) m_cachedThreadGlobalTimerHeap = &threadGlobalTimerHeap(); // Keep heap valid while changing the next-fire time. double oldTime = m_nextFireTime; // Don't realign zero-delay timers. if (newTime) { if (auto newAlignedTime = alignedFireTime(secondsToMS(newTime))) newTime = msToSeconds(newAlignedTime.value()); } if (oldTime != newTime) { m_nextFireTime = newTime; // FIXME: This should be part of ThreadTimers, or another per-thread structure. static std::atomic<unsigned> currentHeapInsertionOrder; m_heapInsertionOrder = currentHeapInsertionOrder++; bool wasFirstTimerInHeap = m_heapIndex == 0; updateHeapIfNeeded(oldTime); bool isFirstTimerInHeap = m_heapIndex == 0; if (wasFirstTimerInHeap || isFirstTimerInHeap) threadGlobalData().threadTimers().updateSharedTimer(); } checkConsistency(); }
// input is UTC void msToGregorianDateTime(ExecState* exec, double ms, bool outputIsUTC, GregorianDateTime& tm) { double dstOff = 0.0; double utcOff = 0.0; if (!outputIsUTC) { utcOff = getUTCOffset(exec); dstOff = getDSTOffset(exec, ms, utcOff); ms += dstOff + utcOff; } const int year = msToYear(ms); tm.second = msToSeconds(ms); tm.minute = msToMinutes(ms); tm.hour = msToHours(ms); tm.weekDay = msToWeekDay(ms); tm.yearDay = dayInYear(ms, year); tm.monthDay = dayInMonthFromDayInYear(tm.yearDay, isLeapYear(year)); tm.month = monthFromDayInYear(tm.yearDay, isLeapYear(year)); tm.year = year - 1900; tm.isDST = dstOff != 0.0; tm.utcOffset = static_cast<long>((dstOff + utcOff) / WTF::msPerSecond); tm.timeZone = NULL; }
void msToGregorianDateTime(double ms, bool outputIsUTC, GregorianDateTime& tm) { // input is UTC double dstOff = 0.0; if (!outputIsUTC) { // convert to local time dstOff = getDSTOffset(ms); ms += dstOff + getUTCOffset(); } tm.second = msToSeconds(ms); tm.minute = msToMinutes(ms); tm.hour = msToHours(ms); tm.weekDay = msToWeekDay(ms); tm.monthDay = msToDayInMonth(ms); tm.yearDay = dayInYear(ms, msToYear(ms)); tm.month = msToMonth(ms); tm.year = msToYear(ms) - 1900; tm.isDST = dstOff != 0.0; tm.utcOffset = static_cast<long>((dstOff + getUTCOffset()) / msPerSecond); tm.timeZone = NULL; }