This source file includes following definitions.
- setToCurrentLocalTime
#include "config.h"
#include "GregorianDateTime.h"
#include "DateMath.h"
#if OS(WIN)
#include <windows.h>
#endif
namespace WTF {
void GregorianDateTime::setToCurrentLocalTime()
{
#if OS(WIN)
SYSTEMTIME systemTime;
GetLocalTime(&systemTime);
TIME_ZONE_INFORMATION timeZoneInformation;
DWORD timeZoneId = GetTimeZoneInformation(&timeZoneInformation);
LONG bias = timeZoneInformation.Bias;
if (timeZoneId == TIME_ZONE_ID_DAYLIGHT)
bias += timeZoneInformation.DaylightBias;
else if (timeZoneId == TIME_ZONE_ID_STANDARD)
bias += timeZoneInformation.StandardBias;
else
ASSERT(timeZoneId == TIME_ZONE_ID_UNKNOWN);
m_year = systemTime.wYear;
m_month = systemTime.wMonth - 1;
m_monthDay = systemTime.wDay;
m_yearDay = dayInYear(m_year, m_month, m_monthDay);
m_weekDay = systemTime.wDayOfWeek;
m_hour = systemTime.wHour;
m_minute = systemTime.wMinute;
m_second = systemTime.wSecond;
m_utcOffset = -bias * secondsPerMinute;
m_isDST = timeZoneId == TIME_ZONE_ID_DAYLIGHT ? 1 : 0;
#else
tm localTM;
time_t localTime = time(0);
localtime_r(&localTime, &localTM);
m_year = localTM.tm_year + 1900;
m_month = localTM.tm_mon;
m_monthDay = localTM.tm_mday;
m_yearDay = localTM.tm_yday;
m_weekDay = localTM.tm_wday;
m_hour = localTM.tm_hour;
m_minute = localTM.tm_min;
m_second = localTM.tm_sec;
m_isDST = localTM.tm_isdst;
#if HAVE(TM_GMTOFF)
m_utcOffset = localTM.tm_gmtoff;
#else
int utcOffset = calculateUTCOffset();
utcOffset += calculateDSTOffset(localTime * msPerSecond, utcOffset);
m_utcOffset = utcOffset / msPerSecond;
#endif
#endif
}
}