[Pkg-mozext-commits] [gcontactsync] 10/31: Issue #52: Update 0 pad for review comments

David Prévot taffit at moszumanska.debian.org
Sun Feb 22 21:34:33 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository gcontactsync.

commit a51c33b3bddc77b459dbcb2e4e74a92eabefbce3
Author: Josh Geenen <joshgeenen at gmail.com>
Date:   Sun Oct 26 12:56:27 2014 -0500

    Issue #52: Update 0 pad for review comments
---
 src/content/ContactConverter.js | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/src/content/ContactConverter.js b/src/content/ContactConverter.js
index b6bbcdc..920ad92 100644
--- a/src/content/ContactConverter.js
+++ b/src/content/ContactConverter.js
@@ -746,18 +746,17 @@ com.gContactSync.ContactConverter = {
     // TB can have all three, just a day/month, or just a year through the UI
     var birthDay    = parseInt(aTBContact.getValue("BirthDay"), 10),
         birthMonth  = (isNaN(birthDay) || (birthDay > 31)) ?
-                      null : aTBContact.getValue("BirthMonth"),
+                      NaN : parseInt(aTBContact.getValue("BirthMonth"), 10),
         birthdayVal = null;
     // if the contact has a birth month (and birth day) add it to the contact
     // from Google
-    if (birthMonth && !isNaN(parseInt(birthMonth, 10)) && (birthMonth <= 12)) {
+    if (!isNaN(birthMonth) && (birthMonth <= 12)) {
       var birthYear = parseInt(aTBContact.getValue("BirthYear"), 10);
       // if the birth year is NaN or 0, use '-'
+      // otherwise pad it to 4 characters
       if (!birthYear) {
         birthYear = "-";
-      }
-      // otherwise pad it to 4 characters
-      else {
+      } else {
         birthYear = String(birthYear);
         while (birthYear.length < 4) {
           birthYear = "0" + birthYear;
@@ -765,12 +764,12 @@ com.gContactSync.ContactConverter = {
       }
       // Pad the birth month to 2 characters
       birthMonth = String(birthMonth);
-      while (birthMonth.length < 2) {
+      if (birthMonth.length < 2) {
         birthMonth = "0" + birthMonth;
       }
       // Pad the birth day to 2 characters
       birthDay = String(birthDay);
-      while (birthDay.length < 2) {
+      if (birthDay.length < 2) {
         birthDay = "0" + birthDay;
       }
       // form the birthday string: year-month-day
@@ -789,20 +788,25 @@ com.gContactSync.ContactConverter = {
   setGoogleAnniversary: function ContactConverter_setGoogleAnniversary(aGContact, aTBContact) {
     var anniversaryDay = parseInt(aTBContact.getValue("AnniversaryDay"), 10);
     var anniversaryMonth = (isNaN(anniversaryDay) || anniversaryDay > 31) ?
-                             null :
+                             NaN :
                              parseInt(aTBContact.getValue("AnniversaryMonth"), 10);
     var anniversaryYear = (isNaN(anniversaryMonth) || anniversaryMonth > 13) ?
-                            null :
+                            NaN :
                             parseInt(aTBContact.getValue("AnniversaryYear"), 10);
-    anniversaryDay = String(anniversaryDay);
-    anniversaryMonth = String(anniversaryMonth);
-    while (anniversaryDay.length < 2) {
-      anniversaryDay = "0" + anniversaryDay;
-    }
-    while (anniversaryMonth.length < 2) {
-      anniversaryMonth = "0" + anniversaryMonth;
+    var anniversaryVal = null;
+
+    if (anniversaryYear) {
+      anniversaryDay = String(anniversaryDay);
+      anniversaryMonth = String(anniversaryMonth);
+      if (anniversaryDay.length < 2) {
+        anniversaryDay = "0" + anniversaryDay;
+      }
+      if (anniversaryMonth.length < 2) {
+        anniversaryMonth = "0" + anniversaryMonth;
+      }
+      anniversaryVal = anniversaryYear + "-" + anniversaryMonth + "-" + anniversaryDay;
     }
-    var anniversaryVal = anniversaryYear ? anniversaryYear + "-" + anniversaryMonth + "-" + anniversaryDay : null;
+
     com.gContactSync.LOGGER.VERBOSE_LOG(" * Anniversary: " + anniversaryVal);
     aGContact.setValue("event", 0, "anniversary", anniversaryVal);
     return anniversaryVal;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/gcontactsync.git



More information about the Pkg-mozext-commits mailing list