Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-8669

CronTab.ceil on workdays returns day in the past

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • core
    • None
    • tested 1.393 and 1.395

      clone of HUDSON-8656

      @Test
      public void testHudsonCeil() throws ANTLRException {
        final Calendar cal = Calendar.getInstance();
        cal.set(2011, 0, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
        final String cronStr = "0 23 * * 1-5"; // execute on weekdays @23:00
        final CronTab cron = new CronTab(cronStr);
        final Calendar next = cron.ceil(cal);
        final Calendar expectedDate = Calendar.getInstance();
        expectedDate.set(2011, 0, 17, 23, 0, 0); // Expected next: Monday, Jan 17th 2011, 23:00
        Assert.assertEquals(expectedDate.get(Calendar.HOUR), next.get(Calendar.HOUR));
        Assert.assertEquals(expectedDate.get(Calendar.MINUTE), next.get(Calendar.MINUTE));
        Assert.assertEquals(expectedDate.get(Calendar.YEAR), next.get(Calendar.YEAR));
        Assert.assertEquals(expectedDate.get(Calendar.MONTH), next.get(Calendar.MONTH));
        Assert.assertEquals(expectedDate.get(Calendar.DAY_OF_MONTH), next.get(Calendar.DAY_OF_MONTH)); // FAILS: is Monday, Jan 10th, 23:00
      }
      

            nairb774 nairb774
            tofuatjava Thomas Fürer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: