From 944c14ab514fc46c0dae5c0923b9626a53a10aaa Mon Sep 17 00:00:00 2001 From: Ricardo de Almeida Gonzaga Date: Tue, 17 Sep 2013 14:00:51 -0300 Subject: [PATCH] [Time] equalsTo, earlierThan and laterThan now are throwing exceptions --- time/time_api.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/time/time_api.js b/time/time_api.js index 2bbfd53..c89acce 100644 --- a/time/time_api.js +++ b/time/time_api.js @@ -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(), -- 2.7.4