[Time] Fix for getDate() and getUTCDate().
authorTomasz Marciniak <t.marciniak@samsung.com>
Fri, 25 Sep 2015 13:03:43 +0000 (15:03 +0200)
committerTomasz Marciniak <t.marciniak@samsung.com>
Fri, 25 Sep 2015 13:03:43 +0000 (15:03 +0200)
[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 <t.marciniak@samsung.com>
src/time/time_api.js

index 11a1fe41acd71765814d5208914125be3e046e8e..dc4f5e61073c92e55ae1845b5751297d2ef8779a 100644 (file)
@@ -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_);
 };