X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fkarma%2Funit%2FcrmMailingRadioDateSpec.js;h=0e47406b3e78563575ab85e364b36c61eb7d408c;hb=6698aeacce6bf12e331128864cb47c581c924124;hp=defda31a0324d9d5e54eed45e86b6fbb53841b45;hpb=d6766e5a1a76ac93bc9a33bfe667f8aeb962ed13;p=civicrm-core.git diff --git a/tests/karma/unit/crmMailingRadioDateSpec.js b/tests/karma/unit/crmMailingRadioDateSpec.js index defda31a03..0e47406b3e 100644 --- a/tests/karma/unit/crmMailingRadioDateSpec.js +++ b/tests/karma/unit/crmMailingRadioDateSpec.js @@ -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();