Skip to content

Commit

Permalink
Add year in if it exists when fudging missing months
Browse files Browse the repository at this point in the history
Fixes #88
  • Loading branch information
simonpoole committed Mar 15, 2024
1 parent 0f90c1a commit d468b8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,7 @@ List < DateRange > date_selector() :
{
DateRange mdr, mdr1;
Month lastMonth = null;
int lastYear = YearRange.UNDEFINED_YEAR;
List < DateRange > result = new ArrayList < DateRange > ();
}
{
Expand All @@ -1129,7 +1130,7 @@ List < DateRange > date_selector() :
< COMMA > mdr1 = date_range()
{
DateWithOffset dwo = mdr1.getStartDate();
// if the month is missing in the start date patch it up here
// if the month and maybe the year is missing in the start date patch it up here
// in strict mode we will never get to this point
if (dwo.getVarDate() == null)
{
Expand All @@ -1142,17 +1143,20 @@ List < DateRange > date_selector() :
{
DateWithOffset first = mdr.getStartDate();
lastMonth = first.getMonth();
lastYear = first.getYear();
if (lastMonth == null)
{
// fail, can't fudge the month
throw new OpeningHoursParseException(tr("missing_month_start"), token.next);
}
}
dwo.setMonth(lastMonth);
dwo.setYear(lastYear);
}
else if (dwo.getMonth() != null)
else
{
lastMonth = dwo.getMonth();
lastYear = dwo.getYear();
}
}
result.add(mdr1);
Expand Down
2 changes: 1 addition & 1 deletion test-data/oh.txt-result
Original file line number Diff line number Diff line change
Expand Up @@ -156254,7 +156254,7 @@
0 Tu-We,Fr 08:30-18:00; Th 08:30-20:00; Sa 08:00-14:00
0 Tu-We,Fr 08:30-18:00; Th 12:00-20:00; Sa 08:00-13:00
0 Tu,We,Fr 08:30-18:30; Th 08:30-19:00; Sa 08:00-13:00
0 Tu,We,Fr 08:30-20:30; Sa 08:30-14:00; Su "8:30-14 ? check website"; Mo,Th closed; 2015 Jun 29-Sep 13 off; 2015 Sep 26-27 off; 2015 Oct 17-18,Oct 31 off; 2015 Nov 29 off
0 Tu,We,Fr 08:30-20:30; Sa 08:30-14:00; Su "8:30-14 ? check website"; Mo,Th closed; 2015 Jun 29-Sep 13 off; 2015 Sep 26-27 off; 2015 Oct 17-18,2015 Oct 31 off; 2015 Nov 29 off
0 Tu,We,Fr 08:45-12:00,13:30-18:00; Th 09:30-12:00,13:30-18:00; Sa 08:45-12:00
0 Tu,We,Fr 08:45-12:00,13:45-18:00; Th 08:45-12:00,14:30-18:00; Sa 08:30-12:30
0 Tu,We,Fr 08:45-12:15,13:30-17:40; Th 09:45-12:15,13:30-17:40; Sa 08:45-12:10; Su,Mo off
Expand Down

0 comments on commit d468b8f

Please sign in to comment.