From bb85d7d8404ec211c2cd8bf201686e11b4607e2c Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Fri, 25 Sep 2015 15:03:43 +0200 Subject: [PATCH] [Time] Fix for getDate() and getUTCDate(). [Verification] TCT pass rate for Alarm, Calendar and Exif is 100% TCT pass rate for Time is 99.79%. One faild test is not related to this change. Change-Id: I6ffba155fd8d9d21a9970868111191a420ac0002 Signed-off-by: Tomasz Marciniak --- src/time/time_api.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/time/time_api.js b/src/time/time_api.js index 11a1fe41..dc4f5e61 100644 --- a/src/time/time_api.js +++ b/src/time/time_api.js @@ -367,7 +367,9 @@ tizen.TZDate = function(year, month, day, hours, minutes, seconds, milliseconds, }; tizen.TZDate.prototype.getDate = function() { - return this.date_.getDate(); + var d = this.addDuration(new tizen.TimeDuration(getTimezoneOffset(this.timezone_, + getMsUTC(this.date_)))); + return d.date_.getUTCDate(); }; tizen.TZDate.prototype.setDate = function() { @@ -464,9 +466,7 @@ tizen.TZDate.prototype.setSeconds = function() { }; tizen.TZDate.prototype.getUTCDate = function() { - var d = this.addDuration(new tizen.TimeDuration(getTimezoneOffset(this.timezone_, - getMsUTC(this.date_)) * -1)); - return d.getDate(); + return this.date_.getUTCDate(); }; tizen.TZDate.prototype.setUTCDate = function() { @@ -798,8 +798,9 @@ tizen.TZDate.prototype.getPreviousDSTTransition = function() { var _result = native_.getResultObject(result); if (result.error || _result === 0) return null; - var OffsetInMilliseconds = this.date_.getTimezoneOffset() * _minuteInMilliseconds * -1; - return new tizen.TZDate(new Date(_result - OffsetInMilliseconds), this.timezone_); + + var utc_time = getMsUTC(new Date(_result), this.timezone_); + return new tizen.TZDate(new Date(utc_time)).toTimezone(this.timezone_); }; tizen.TZDate.prototype.getNextDSTTransition = function() { @@ -814,6 +815,7 @@ tizen.TZDate.prototype.getNextDSTTransition = function() { var _result = native_.getResultObject(result); if (result.error || _result === 0) return null; - var OffsetInMilliseconds = this.date_.getTimezoneOffset() * _minuteInMilliseconds * -1; - return new tizen.TZDate(new Date(_result - OffsetInMilliseconds), this.timezone_); + + var utc_time = getMsUTC(new Date(_result), this.timezone_); + return new tizen.TZDate(new Date(utc_time)).toTimezone(this.timezone_); }; -- 2.34.1