cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omef...@apache.org
Subject cordova-plugin-contacts git commit: handle 'Invalid Date' error
Date Fri, 06 May 2016 22:51:19 GMT
Repository: cordova-plugin-contacts
Updated Branches:
  refs/heads/master 956c76b50 -> e4d72c341


handle 'Invalid Date' error

 This closes #125


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/e4d72c34
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/e4d72c34
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/e4d72c34

Branch: refs/heads/master
Commit: e4d72c34131cb0331bdc2839e73156e99ab6dc22
Parents: 956c76b
Author: TanaseButcaru <contact@butcaru.com>
Authored: Fri May 6 23:08:40 2016 +0300
Committer: Omar Mefire <omefire@gmail.com>
Committed: Fri May 6 15:50:52 2016 -0700

----------------------------------------------------------------------
 www/convertUtils.js | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/e4d72c34/www/convertUtils.js
----------------------------------------------------------------------
diff --git a/www/convertUtils.js b/www/convertUtils.js
index 5d997d8..1a1ec64 100644
--- a/www/convertUtils.js
+++ b/www/convertUtils.js
@@ -28,10 +28,19 @@ module.exports = {
     */
     toCordovaFormat: function (contact) {
         var value = contact.birthday;
-        try {
-          contact.birthday = new Date(parseFloat(value));
-        } catch (exception){
-          console.log("Cordova Contact toCordovaFormat error: exception creating date.");
+        if (value !== null) {
+            try {
+              contact.birthday = new Date(parseFloat(value));
+              
+              //we might get 'Invalid Date' which does not throw an error
+              //and is an instance of Date.
+              if (isNaN(contact.birthday.getTime())) {
+                contact.birthday = null;
+              }
+
+            } catch (exception){
+              console.log("Cordova Contact toCordovaFormat error: exception creating date.");
+            }
         }
         return contact;
     },


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message