From b26922d079ef17fac8e02a3e15f708e33c13708c Mon Sep 17 00:00:00 2001
From: Piotr Kosko
Date: Fri, 20 May 2016 11:42:25 +0200
Subject: [PATCH] Fixed a bug in TZDate constructor
[Bug] With following conditions:
1. Device local timezone uses DST.
2. current date has +1 hour according to DST.
3. Creating new tizen date with local timezone, on which date there would not be +1 hour DST
created date would have incorrect time.
Example:
1. using timezone 'Europe/Warsaw'
2. current date 20.05.2016 (+2 hour from UTC = 1 (for timezone) + 1 (for DST))
3. line below returned 13, which was incorrect:
var d = new tizen.TZDate(new Date(2016,01,20,13)); d.getHours();
[Verification] TCT passrate time - 100%.
Verified in console - above example returned '13' which was correct value.
Change-Id: Iffff14814d2c5011561158cc7bd1db215659953a
Signed-off-by: Piotr Kosko
---
src/time/time_api.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/time/time_api.js b/src/time/time_api.js
index a29071d6..ea6962b6 100644
--- a/src/time/time_api.js
+++ b/src/time/time_api.js
@@ -66,8 +66,8 @@ function _getTimezoneOffset(timestamp, tzName) {
return res;
}
-function _getLocalTimezoneOffset() {
- return -1 * (new Date().getTimezoneOffset()) * 60 * 1000; // cast to milliseconds
+function _getLocalTimezoneOffset(utcTimestamp) {
+ return -1 * (new Date(utcTimestamp).getTimezoneOffset()) * 60 * 1000; // cast to milliseconds
}
function _constructTZDate(obj, privateTZDate) {
@@ -82,7 +82,7 @@ function _constructTZDate(obj, privateTZDate) {
tzName = tizen.time.getLocalTimezone();
if (T.isNullOrUndefined(offset)) {
- offset = _getLocalTimezoneOffset();
+ offset = _getLocalTimezoneOffset(utcTimestamp);
}
break;
@@ -145,8 +145,8 @@ tizen.TZDate = function(p1, p2, day, hours, minutes, seconds, milliseconds, time
date = new Date(p1, p2, day, hours, minutes, seconds, milliseconds);
}
- var offset = _getLocalTimezoneOffset();
var utcTimestamp = date.getTime();
+ var offset = _getLocalTimezoneOffset(utcTimestamp);
var tzName = _LOCAL_ID;
if (!T.isNullOrUndefined(timezone)) {
--
2.34.1