result
_SystemTimeImpl::GetCurrentTime(TimeMode timeMode, DateTime& currentTime)
{
+ struct tm gmTime;
struct tm* pGmTime = null;
- time_t currTime = 0;
TimeZone timeZone;
DateTime tempTime;
struct timeval currentTimeVal;
_LocaleManagerImpl* plm = null;
- time(&currTime);
- SysLog(NID_SYS, "Current Epoch is %lld.", currTime);
gettimeofday(¤tTimeVal, null);
+ SysLog(NID_SYS, "Current Epoch is %lld.", currentTimeVal.tv_sec);
- pGmTime = gmtime(&currTime);
- SysTryReturnResult(NID_SYS, null != pGmTime, E_SYSTEM, "Failed to convert the time value to UTC time");
- SysLog(NID_SYS, "Calendar time is sec:%d, min:%d, hour:%d, day:%d, mon:%d, year:%d, wday%d, year:%d, dst:%d", pGmTime->tm_sec, pGmTime->tm_min, pGmTime->tm_hour, pGmTime->tm_mday, pGmTime->tm_mon, pGmTime->tm_year, pGmTime->tm_wday, pGmTime->tm_yday, pGmTime->tm_isdst);
+ pGmTime = gmtime_r(¤tTimeVal.tv_sec, &gmTime);
+ SysTryReturnResult(NID_SYS, null != pGmTime, E_SYSTEM, "It is failed to convert the time value to UTC time");
+ SysLog(NID_SYS, "Calendar time is sec:%d, min:%d, hour:%d, day:%d, mon:%d, year:%d, wday%d, year:%d, dst:%d", gmTime.tm_sec, gmTime.tm_min, gmTime.tm_hour, gmTime.tm_mday, gmTime.tm_mon, gmTime.tm_year, gmTime.tm_wday, gmTime.tm_yday, gmTime.tm_isdst);
plm = new (std::nothrow) _LocaleManagerImpl();
SysTryReturnResult(NID_SYS, null != plm, E_SYSTEM, "_LocaleManagerImpl instance must not be null");
String timeZoneId = timeZone.GetId();
int rawOffset = timeZone.GetRawOffset();
int dstSavings = timeZone.GetDstSavings();
- SysLog(NID_SYS, "Time zone: %S, %d, %d", timeZoneId.GetPointer(), rawOffset, dstSavings);
+ SysLog(NID_SYS, "Current time zone is %S, %d, %d", timeZoneId.GetPointer(), rawOffset, dstSavings);
+ tempTime.SetValue(gmTime.tm_year + 1900, gmTime.tm_mon + 1, gmTime.tm_mday, gmTime.tm_hour, gmTime.tm_min, gmTime.tm_sec, currentTimeVal.tv_usec / 1000);
- tempTime.SetValue(pGmTime->tm_year + 1900, pGmTime->tm_mon + 1, pGmTime->tm_mday, pGmTime->tm_hour, pGmTime->tm_min, pGmTime->tm_sec, currentTimeVal.tv_usec / 1000);
-
- SysLog(NID_SYS, "Original Time %d %d/%d, %d:%d:%d:%d", tempTime.GetYear(), tempTime.GetMonth(), tempTime.GetDay(), tempTime.GetHour(), tempTime.GetMinute(), tempTime.GetSecond(), tempTime.GetMillisecond());
+ SysLog(NID_SYS, "Original Time is %d %d/%d, %d:%d:%d:%d", tempTime.GetYear(), tempTime.GetMonth(), tempTime.GetDay(), tempTime.GetHour(), tempTime.GetMinute(), tempTime.GetSecond(), tempTime.GetMillisecond());
switch (timeMode)
{
break;
}
- SysLog(NID_SYS, "Current Time %d %d/%d, %d:%d:%d", currentTime.GetYear(), currentTime.GetMonth(), currentTime.GetDay(), currentTime.GetHour(), currentTime.GetMinute(), currentTime.GetSecond());
+ SysLog(NID_SYS, "Current Time is %d %d/%d, %d:%d:%d", currentTime.GetYear(), currentTime.GetMonth(), currentTime.GetDay(), currentTime.GetHour(), currentTime.GetMinute(), currentTime.GetSecond());
return E_SUCCESS;
}