Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#632: Implement support for starting point of intervals #633

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected String describe(final Between between, final boolean and) {
protected String describe(final Every every, final boolean and) {
String description;
if (every.getPeriod().getValue() > 1) {
description = String.format("%s %s ", bundle.getString(EVERY), nominalValue(every.getPeriod()))
description = String.format("%s %s ", bundle.getString(EVERY), every.getPeriod())
+ " replace_plural ";
} else {
description = bundle.getString(EVERY) + " %s ";
Expand All @@ -167,6 +167,10 @@ protected String describe(final Every every, final boolean and) {
description += MessageFormat.format(bundle.getString("between_x_and_y"), nominalValue(between.getFrom()),
nominalValue(between.getTo())) + WHITE_SPACE;
}
if (every.getExpression() instanceof On) {
final On on = (On) every.getExpression();
description += bundle.getString("from") + " %s " + nominalValue(on.getTime());
}
return description;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/com/cronutils/CronUtilsI18N.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=between {0} and {1}
every=every
and=and
at=at
from=from
day=day
days=days
hour=hour
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=zwischen {0} und {1}
every=jede
and=und
at=um
from=von
day=Tag
days=Tage
hour=Stunde
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=\u03BC\u03B5\u03C4\u03B1\u03BE\u03CD {0} \u03BA\u03B1\u03B9 {1}
every=\u03BA\u03AC\u03B8\u03B5
and=\u03BA\u03B1\u03B9
at=\u03C3\u03C4\u03BF/\u03C3\u03C4\u03B7/\u03C3\u03C4\u03B9\u03C2/\u03C4\u03B7
from=\u03B1\u03C0\u03CC
day=\u03BC\u03AD\u03C1\u03B1
days=\u03BC\u03AD\u03C1\u03B5\u03C2
hour=\u03CE\u03C1\u03B1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=between {0} and {1}
every=every
and=and
at=at
from=from
day=day
days=days
hour=hour
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/com/cronutils/CronUtilsI18N_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=entre {0} y {1}
every=cada
and=y
at=en
from=de
day=dia
days=dias
hour=hora
Expand All @@ -21,6 +22,6 @@ last=ultimo
the_nearest_weekday_to_the=dia de semana mas cercano a
last_day_of_month=ultimo dia del mes
last_weekday_of_month=ultimo dia de semana del mes
day_before_last_day_of_month=un d�a antes del �ltimo d�a del mes
days_before_last_day_of_month={0} d�as antes del �ltimo d�a del mes
day_before_last_day_of_month=un d�a antes del �ltimo d�a del mes
days_before_last_day_of_month={0} d�as antes del �ltimo d�a del mes

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ every=chaque
second=seconde
and=et
at=\u00e0
from=de
day=jour
hour=heure
hours=heures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=antara {0} dan {1}
every=setiap
and=dan
at=di
from=dari
day=hari
days=hari
hour=jam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=tra {0} e {1}
every=ogni
and=e
at=alle
from=da
day=giorno
days=giorni
hour=ora
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/com/cronutils/CronUtilsI18N_ja.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
between_x_and_y={0}\u3068{1}\u306e\u9593
every=\u6bce
and=\u3068
at=
at=\u306b
from=\u304b\u3089
day=\u65e5
days=\u65e5
hour=\u6642
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y={0} ~ {1} \uAE4C\uC9C0
every=\uB9E4
and=\uD558\uACE0
at=\uB9E4
from=\uC5C6\uC74C
day=\uC77C
days=\uC77C
hour=\uC2DC\uAC04
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=tussen {0} en {1}
every=elke
and=en
at=om
from=van
day=dag
days=dagen
hour=uur
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=mi\u0119dzy {0} oraz {1}
every=ka\u017Cdy
and=oraz
at=o
from=od
day=dzie\u0144
days=dni
hour=godzina
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ every=cada
second=segundo
and=e
at=em
from=de
day=dia
days=dias
hour=hora
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=intre {0} si {1}
every=fiecare
and=\u015Fi
at=at
from=de la
day=zi
days=zile
hour=ora
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=\u043c\u0435\u0436\u0434\u0443 {0} \u0438 {1}
every=\u043a\u0430\u0436\u0434\u044b\u0439
and=\u0438
at=\u0432
from=\u0441
day=\u0434\u0435\u043d\u044c
days=\u0434\u043d\u0438
hour=\u0447\u0430\u0441
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=kutoka {0} hadi {1}
every=kila
and=na
at=mnamo
from=kutoka
day=siku
days=siku
hour=saa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y={0} ve {1} aras\u0131nda
every=her
and=ve
at=\u015Fu zamanda :
from=itibaren
day=g\u00FCn
days=g\u00FC
hour=saat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ between_x_and_y=\u5728{0}\u548c{1}\u4e4b\u95f4
every=\u6bcf
and=\u548c
at=\u5728
from=\u4ece
day=\u5929
days=\u5929
hour=\u5c0f\u65f6
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/cronutils/Issue440Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void testCase1() {
CronDescriptor descriptor = CronDescriptor.instance(Locale.UK);
String description = descriptor.describe(parser.parse("* 2,1/31 * * * ?"));

assertEquals("every second at minute 2 and every 31 minutes", description);
assertEquals("every second at minute 2 and every 31 minutes from minute 1", description);
}

@Test
Expand All @@ -27,6 +27,6 @@ public void testCase2() {
CronDescriptor descriptor = CronDescriptor.instance(Locale.UK);
String description = descriptor.describe(parser.parse("2,1/31 * * * *"));

assertEquals("at minute 2 and every 31 minutes", description);
assertEquals("at minute 2 and every 31 minutes from minute 1", description);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,22 @@ public void testEveryMinuteBetween14and15EveryDay() {

@Test
public void testEveryFiveMinutesBetween14and15EveryDay() {
assertExpression("0 0/5 14 * * ?", "every 5 minutes at 14 hour");
assertExpression("0 0/5 14 * * ?", "every 5 minutes from minute 0 at 14 hour");
}

@Test
public void testEveryFiveMinutesBetween14and15AndBetween18And19EveryDay() {
assertExpression("0 0/5 14,18 * * ?", "every 5 minutes at 14 and 18 hours");
assertExpression("0 0/5 14,18 * * ?", "every 5 minutes from minute 0 at 14 and 18 hours");
}

@Test
public void testEveryFiveDaysStartingOnDay3OfTheMonth() {
assertExpression("0 0 0 3/5 * ?", "at 00:00 every 5 days from day 3");
}

@Test
public void testEveryFiveDaysStartingOnTuesday() {
assertExpression("0 0 0 ? * 3/5", "at 00:00 every 5 days from day Tuesday");
}

/**
Expand All @@ -113,7 +123,7 @@ public void testEveryDayEveryFourHoursFromHour2() {
*/
@Test
public void testDescriptionDayOfWeek() {
assertExpression("* 0/1 * ? * TUE", "every second every minute at Tuesday day");
assertExpression("* 0/1 * ? * TUE", "every second every minute from minute 0 at Tuesday day");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static Stream<Expr> expressions() {
new Expr("*/10 * * * * *", "every 10 seconds"),
new Expr("0 0 8-10 * * *", "every hour between 8 and 10"),
new Expr("0 0 6,19 * * *", "at 6 and 19 hours"),
new Expr("0 0/30 8-10 * * *", "every 30 minutes every hour between 8 and 10"),
new Expr("0 0/30 8-10 * * *", "every 30 minutes from minute 0 every hour between 8 and 10"),
new Expr("0 0 9-17 * * MON-FRI", "every hour between 9 and 17 every day between Monday and Friday")
);
}
Expand Down