[Time] equalsTo, earlierThan and laterThan now are throwing exceptions
authorRicardo de Almeida Gonzaga <ricardo.gonzaga@intel.com>
Tue, 17 Sep 2013 17:00:51 +0000 (14:00 -0300)
committerRicardo de Almeida Gonzaga <ricardo.gonzaga@intel.com>
Wed, 18 Sep 2013 13:50:17 +0000 (10:50 -0300)
time/time_api.js

index 2bbfd53..c89acce 100644 (file)
@@ -227,13 +227,34 @@ tizen.TZDate = (function() {
                                       other.getTime(), 'MSEC');
       },
       equalsTo: function(other) {
-        return this.getTime() == other.getTime();
+        try {
+            return this.getTime() == other.getTime();
+        } catch (e) {
+            if (e instanceof TypeError)
+              throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+            else if (e instanceof RangeError)
+              throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+        }
       },
       earlierThan: function(other) {
-        return this.getTime() < other.getTime();
+        try {
+            return this.getTime() < other.getTime();
+        } catch (e) {
+            if (e instanceof TypeError)
+              throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+            else if (e instanceof RangeError)
+              throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+        }
       },
       laterThan: function(other) {
-        return this.getTime() > other.getTime();
+        try {
+            return this.getTime() > other.getTime();
+        } catch(e) {
+            if (e instanceof TypeError)
+              throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+            else if (e instanceof RangeError)
+              throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+        }
       },
       addDuration: function(duration) {
         var date = new TZDate(date_.getFullYear(), date_.getMonth(),