Skip to content

Commit ee7e07a

Browse files
committed
Describe "always ..." for HHMMSS
1 parent 01650a0 commit ee7e07a

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/main/java/com/cronutils/descriptor/TimeDescriptionStrategy.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,23 @@ public String describe() {
9191
}
9292
String secondsDesc = "";
9393
String minutesDesc = "";
94-
final String hoursDesc = addTimeExpressions(describe(hours), bundle.getString(HOUR),
95-
bundle.getString("hours"));
96-
if (!(seconds instanceof On && isDefault((On) seconds))) {
97-
secondsDesc = addTimeExpressions(describe(seconds), bundle.getString(SECOND), bundle.getString("seconds"));
94+
String hoursDesc = "";
95+
if (!(hours instanceof Always)) {
96+
hoursDesc = addTimeExpressions(describe(hours), bundle.getString(HOUR), bundle.getString("hours"));
9897
}
99-
if (!(minutes instanceof On && isDefault((On) minutes))) {
98+
if (!(minutes instanceof On && isDefault((On) minutes)) && !((minutes instanceof Always) && (hours instanceof Always))) {
10099
minutesDesc = addTimeExpressions(describe(minutes), bundle.getString(MINUTE), bundle.getString("minutes"));
101100
}
101+
if (!(seconds instanceof On && isDefault((On) seconds))) {
102+
secondsDesc = addTimeExpressions(describe(seconds), bundle.getString(SECOND), bundle.getString("seconds"));
103+
}
102104
return String.format("%s %s %s", secondsDesc, minutesDesc, hoursDesc);
103105
}
104106

107+
protected String describe(final Always always, final boolean and) {
108+
return describe(new Every(new IntegerFieldValue(1)), and);
109+
}
110+
105111
private String addTimeExpressions(final String description, final String singular, final String plural) {
106112
return description.replaceAll("%s", singular).replaceAll("replace_plural", plural);
107113
}

src/test/java/com/cronutils/utils/descriptor/CronDescriptorQuartzIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void testEveryDayFireAtTenFifteenYear2005() {
8787

8888
@Test
8989
public void testEveryMinuteBetween14and15EveryDay() {
90-
assertExpression("0 * 14 * * ?", "at 14 hour");
90+
assertExpression("0 * 14 * * ?", "every minute at 14 hour");
9191
}
9292

9393
@Test
@@ -113,7 +113,7 @@ public void testEveryDayEveryFourHoursFromHour2() {
113113
*/
114114
@Test
115115
public void testDescriptionDayOfWeek() {
116-
assertExpression("* 0/1 * ? * TUE", "every minute at Tuesday day");
116+
assertExpression("* 0/1 * ? * TUE", "every second every minute at Tuesday day");
117117
}
118118

119119
/**

0 commit comments

Comments
 (0)