Merge pull request #15483 from demeritcowboy/say-my-name-2
[civicrm-core.git] / tests / karma / unit / crmMailingRadioDateSpec.js
index defda31a0324d9d5e54eed45e86b6fbb53841b45..0e47406b3e78563575ab85e364b36c61eb7d408c 100644 (file)
@@ -87,8 +87,18 @@ describe('crmMailingRadioDate', function() {
       expect(element.find('.crm-form-time').timeEntry('getTime').getMinutes()).toBe(3);
 
       var now = new Date();
-      var month = '' + (now.getMonth() + 1);
-      var day = '' + (now.getDate() + 1);
+      var month = '';
+      var day = '';
+      if (now.getMonth() == 12) {
+        month = '1';
+      } else {
+        month = month + (now.getMonth() + 1);
+      }
+      if (now.getDate() >= 28) {
+        day = '1';
+      } else {
+        day = day + (now.getDate() + 1);
+      }
       var year = (now.getFullYear() + 1);
       if (day.length < 2) day = '0' + day;
       if (month.length < 2) month = '0' + month;
@@ -97,7 +107,10 @@ describe('crmMailingRadioDate', function() {
       var datenow = [year, month, day].join('-');
       var time = [hours, minutes, "00"].join(':');
       var currentDate = datenow + ' ' + time;
-      var ndate = new Date(datenow);
+      // Using datenow in the constructor here converts to local time. If not
+      // running on GMT (or east) then comparison to toDateString below fails.
+      // Also use month-1 because...javascript.
+      var ndate = new Date(year, month-1, day, 0, 0, 0);
       model.the_date = currentDate;
 
       $rootScope.$digest();