{"action":"created","issue":{"url":"https://api.github.com/repos/jmrozanec/cron-utils/issues/37","labels_url":"https://api.github.com/repos/jmrozanec/cron-utils/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/jmrozanec/cron-utils/issues/37/comments","events_url":"https://api.github.com/repos/jmrozanec/cron-utils/issues/37/events","html_url":"https://github.com/jmrozanec/cron-utils/issues/37","id":103765224,"number":37,"title":"nextExecution not working for '0/30 * * * * *'","user":{"login":"strmer15","id":8160654,"avatar_url":"https://avatars.githubusercontent.com/u/8160654?v=3","gravatar_id":"","url":"https://api.github.com/users/strmer15","html_url":"https://github.com/strmer15","followers_url":"https://api.github.com/users/strmer15/followers","following_url":"https://api.github.com/users/strmer15/following{/other_user}","gists_url":"https://api.github.com/users/strmer15/gists{/gist_id}","starred_url":"https://api.github.com/users/strmer15/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strmer15/subscriptions","organizations_url":"https://api.github.com/users/strmer15/orgs","repos_url":"https://api.github.com/users/strmer15/repos","events_url":"https://api.github.com/users/strmer15/events{/privacy}","received_events_url":"https://api.github.com/users/strmer15/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jmrozanec/cron-utils/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/jmrozanec/cron-utils/labels/helpwanted","name":"helpwanted","color":"0052cc"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-08-28T17:52:19Z","updated_at":"2015-10-15T03:28:22Z","closed_at":"2015-10-15T03:28:22Z","body":"For the cron expression 0/30 * * * * *, with a custom definition of:\r\n\r\n// Unix Crontab with seconds allowed\r\nCronDefinition cronDefinition = CronDefinitionBuilder.defineCron()\r\n                .withSeconds().and()\r\n                .withMinutes().and()\r\n                .withHours().and()\r\n                .withDayOfMonth().and()\r\n                .withMonth().and()\r\n                .withDayOfWeek().withValidRange(0, 7).withMondayDoWValue(1).withIntMapping(7, 0).and()\r\n                .instance();\r\n\r\nPerforming a nextExecution call when the input DateTime value is between 30 and 59 seconds of the minute causes the method to return with a DateTime at the previous minute instead of the next minute.\r\n\r\nFor example:\r\n\r\nnextExecution('2015-08-28 12:05:44') -> 2015-08-28 12:05:00\r\nnextExecution('2015-08-28 12:05:14') -> 2015-08-28 12:05:30\r\n\r\nNote that I've also tried this with '*/30 * * * * *' and got the same results.\r\n\r\nUnit tests:\r\n\r\n    @Test\r\n    public void testCronExpressionAfterHalf() {\r\n\r\n        CronDefinition cronDefinition = CronDefinitionBuilder.defineCron()\r\n                .withSeconds().and()\r\n                .withMinutes().and()\r\n                .withHours().and()\r\n                .withDayOfMonth().and()\r\n                .withMonth().and()\r\n                .withDayOfWeek().withValidRange(0, 7).withMondayDoWValue(1).withIntMapping(7, 0).and()\r\n                .instance();\r\n\r\n        CronParser parser = new CronParser(cronDefinition);\r\n        Cron cron = parser.parse(\"*/30 * * * * *\");\r\n\r\n        MutableDateTime mutableDateTime = new MutableDateTime();\r\n        mutableDateTime.setDateTime(2015, 8, 28, 12, 5, 44, 0);\r\n\r\n        DateTime startDateTime = mutableDateTime.toDateTime();\r\n\r\n        mutableDateTime = new MutableDateTime();\r\n        mutableDateTime.setDateTime(2015, 8, 28, 12, 6, 0, 0);\r\n\r\n        DateTime expectedDateTime = mutableDateTime.toDateTime();\r\n\r\n        ExecutionTime executionTime = ExecutionTime.forCron(cron);\r\n\r\n        DateTime nextExecutionDateTime = executionTime.nextExecution(startDateTime);\r\n        MatcherAssert.assertThat(nextExecutionDateTime, Matchers.equalTo(expectedDateTime));\r\n    }\r\n\r\n    @Test\r\n    public void testCronExpressionBeforeHalf() {\r\n\r\n        CronDefinition cronDefinition = CronDefinitionBuilder.defineCron()\r\n                .withSeconds().and()\r\n                .withMinutes().and()\r\n                .withHours().and()\r\n                .withDayOfMonth().and()\r\n                .withMonth().and()\r\n                .withDayOfWeek().withValidRange(0, 7).withMondayDoWValue(1).withIntMapping(7, 0).and()\r\n                .instance();\r\n\r\n        CronParser parser = new CronParser(cronDefinition);\r\n        Cron cron = parser.parse(\"0/30 * * * * *\");\r\n\r\n        MutableDateTime mutableDateTime = new MutableDateTime();\r\n        mutableDateTime.setDateTime(2015, 8, 28, 12, 5, 14, 0);\r\n\r\n        DateTime startDateTime = mutableDateTime.toDateTime();\r\n\r\n        mutableDateTime = new MutableDateTime();\r\n        mutableDateTime.setDateTime(2015, 8, 28, 12, 5, 30, 0);\r\n\r\n        DateTime expectedDateTime = mutableDateTime.toDateTime();\r\n\r\n        ExecutionTime executionTime = ExecutionTime.forCron(cron);\r\n\r\n        DateTime nextExecutionDateTime = executionTime.nextExecution(startDateTime);\r\n        MatcherAssert.assertThat(nextExecutionDateTime, Matchers.equalTo(expectedDateTime));\r\n    }"},"comment":{"url":"https://api.github.com/repos/jmrozanec/cron-utils/issues/comments/148271681","html_url":"https://github.com/jmrozanec/cron-utils/issues/37#issuecomment-148271681","issue_url":"https://api.github.com/repos/jmrozanec/cron-utils/issues/37","id":148271681,"user":{"login":"jmrozanec","id":1128080,"avatar_url":"https://avatars.githubusercontent.com/u/1128080?v=3","gravatar_id":"","url":"https://api.github.com/users/jmrozanec","html_url":"https://github.com/jmrozanec","followers_url":"https://api.github.com/users/jmrozanec/followers","following_url":"https://api.github.com/users/jmrozanec/following{/other_user}","gists_url":"https://api.github.com/users/jmrozanec/gists{/gist_id}","starred_url":"https://api.github.com/users/jmrozanec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmrozanec/subscriptions","organizations_url":"https://api.github.com/users/jmrozanec/orgs","repos_url":"https://api.github.com/users/jmrozanec/repos","events_url":"https://api.github.com/users/jmrozanec/events{/privacy}","received_events_url":"https://api.github.com/users/jmrozanec/received_events","type":"User","site_admin":false},"created_at":"2015-10-15T03:28:22Z","updated_at":"2015-10-15T03:28:22Z","body":"@strmer15 the issue was fixed! Will release a new version of cron-utils before weekend."}}