Add / delimiter to the end of ringtones directory path
[platform/framework/native/appfw.git] / src / system / FSys_SystemTimeImpl.cpp
index 62d6aa1..d59b4e7 100644 (file)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
@@ -24,7 +23,7 @@
 #include <new>
 #include <sys/sysinfo.h>
 #include <sys/time.h>
-#include <time.h>
+#include <ctime>
 #include <vconf.h>
 
 #include <FBaseDateTime.h>
@@ -74,19 +73,20 @@ _SystemTimeImpl::GetUptime(TimeSpan& uptime)
 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);
        gettimeofday(&currentTimeVal, 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");
+       pGmTime = gmtime_r(&currentTimeVal.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");
@@ -96,12 +96,11 @@ _SystemTimeImpl::GetCurrentTime(TimeMode timeMode, DateTime& currentTime)
        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)
        {
@@ -121,7 +120,7 @@ _SystemTimeImpl::GetCurrentTime(TimeMode timeMode, DateTime& currentTime)
                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;
 }
@@ -139,7 +138,7 @@ _SystemTimeImpl::SetCurrentTime(const DateTime& currentTime)
 
        ArrayList requestMessage;
        ArrayList responseMessage;
-       char datetime[32] = {0,};
+       char datetime[64] = {0,};
 
        LocaleManager localeManager;
        localeManager.Construct();