incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [1/21] git commit: fixing lost conversion functions in merge
Date Thu, 15 Mar 2012 19:36:24 GMT
Updated Branches:
  refs/heads/master 574da1a65 -> 210bb2049


fixing lost conversion functions in merge


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/210bb204
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/210bb204
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/210bb204

Branch: refs/heads/master
Commit: 210bb2049afef67f6f2cfb13a118448c3a687801
Parents: 1d63465
Author: Fil Maj <maj.fil@gmail.com>
Authored: Thu Mar 15 10:27:24 2012 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Thu Mar 15 10:27:24 2012 -0700

----------------------------------------------------------------------
 lib/plugin/Contact.js |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/210bb204/lib/plugin/Contact.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Contact.js b/lib/plugin/Contact.js
index bc39794..261bb12 100644
--- a/lib/plugin/Contact.js
+++ b/lib/plugin/Contact.js
@@ -16,8 +16,29 @@ function convertIn(contact) {
     return contact;
 };
 
+/**
+* Converts Complex objects into primitives
+* Only conversion at present is for Dates.
+**/
 
-	// convert birthday value to milliseconds - don't modify original(this) contact
+function convertOut(contact) {
+    var value = contact.birthday;
+    if (value != null) {
+        // try to make it a Date object if it is not already
+        if (!value instanceof Date){
+            try {
+                value = new Date(value);
+            } catch(exception){
+                value = null;
+            }
+        }
+        if (value instanceof Date){
+            value = value.valueOf(); // convert to milliseconds
+        }
+        contact.birthday = value;
+    }
+    return contact;
+};
 
 /**
 * Contains information about a single contact.
@@ -148,7 +169,7 @@ Contact.prototype.save = function(successCB, errorCB) {
           fail(ContactError.UNKNOWN_ERROR);
       }
   };
-	var dupContact = utils.clone(this);
+	var dupContact = convertOut(utils.clone(this));
 	exec(success, fail, "Contacts", "save", [dupContact]);
 };
 


Mime
View raw message