From: Tomasz Marciniak Date: Fri, 25 Sep 2015 13:03:43 +0000 (+0200) Subject: [Time] Fix for getDate() and getUTCDate(). X-Git-Tag: submit/tizen/20151026.073646^2^2~76 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb85d7d8404ec211c2cd8bf201686e11b4607e2c;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [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 --- 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_); };