[Messaging] Fix in toTimeT method
authorLukasz Bardeli <l.bardeli@samsung.com>
Thu, 30 Apr 2015 12:04:19 +0000 (14:04 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 4 May 2015 08:54:53 +0000 (17:54 +0900)
[Verification] Code compiles without error.
               Passrate 100% (184/184/0/0/0)

Change-Id: I43c6040ccb21f36bf56985d003103df69e046c86
Signed-off-by: Lukasz Bardeli <l.bardeli@samsung.com>
src/messaging/MsgCommon/Any.cpp

index 31dfe1e5214c4b261e9ed3363405b803ab2caf33..cb4bcab25a6e3a32b23d64f5cb61f97786aace31 100644 (file)
@@ -165,7 +165,13 @@ std::time_t Any::toTimeT() const
     std::time_t current_time;
     std::time(&current_time);
     std::tm* timeinfo = std::localtime(&current_time);
-    return mktime(toDateTm()) + timeinfo->tm_gmtoff;
+    long int gmtoff = timeinfo->tm_gmtoff;
+    if (timeinfo->tm_isdst) {
+      // if dst is set then 1 hour should be subtracted.
+      // 1 hour = 60 second * 60 minutes = 3600 seconds
+      gmtoff -= 3600;
+    }
+    return mktime(toDateTm()) + gmtoff;
 }
 
 } // Tizen