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

The 'either' statement is incorrectly parsed via cfg #62

Closed
karloyz opened this issue Jul 4, 2024 · 4 comments · Fixed by #64
Closed

The 'either' statement is incorrectly parsed via cfg #62

karloyz opened this issue Jul 4, 2024 · 4 comments · Fixed by #64
Assignees
Labels
bug Something isn't working

Comments

@karloyz
Copy link

karloyz commented Jul 4, 2024

I am currently testing this holiday library, and I configured US Independence Day like this:

holiday either  JUL  4 or if SUN then fixed JUL 5         Independence Day
holiday either  JUL  4 or if Sat then fixed JUL 3         Independence Day

However, the result for Year 2026 Jul 4 is mis-parsed as Jul 5. (Jul 3 is expected).

I debugged into the code, and found this place has an issue:

HolidayMatcher.java

	public ConditionBuilder createConditionBuilder(Matcher matcher) {
		return new ConditionBuilder()
				.withDaysOfWeek(daysOfWeek(matcher.group(Patterns.PIVOT_DAYS_OF_WEEK_GROUP)))
				.withPivotDate(monthDay(
						matcher.group(Patterns.**MONTH_GROUP_2**), matcher.group(Patterns.**DAY_GROUP_2**)));
	}

In this code, the matcher should use Patterns.MONTH_GROUP and Patterns.DAY_GROUP instread.

Kindly check or if I can fix with a pull request?

Thanks

@ckunki
Copy link
Collaborator

ckunki commented Jul 5, 2024

Hello @karloyz many thanks for your issue report and special thanks for being that precise.
I will fix the issue during the weekend and provide an updated version.

@ckunki ckunki self-assigned this Jul 5, 2024
@ckunki ckunki added the bug Something isn't working label Jul 5, 2024
kaklakariada added a commit that referenced this issue Jul 7, 2024
* Updated changelog

* Added exclicit encoding to build.gradle

* hashcode and equals methods

Re-generated and added where these were missing

* Added tests for hash code and equals

* Added tests for bugfix

* Added java doc

* Fixed javadoc findings

* Fixed javadoc findings 2

* generated license headers for new files

* Fixed tests and implementation

* Fixed Code smells

* fixed test

* Apply suggestions from code review

* Fail on javadoc warnings

* Fix jacoco setup

* Fix sonar findings

---------

Co-authored-by: Christoph Pirkl <[email protected]>
Co-authored-by: kaklakariada <[email protected]>
@karloyz
Copy link
Author

karloyz commented Jul 7, 2024

@ckunki Thank you for quick response and fix! It's a wonderful library that helped a lot!

@kaklakariada
Copy link
Contributor

kaklakariada commented Jul 7, 2024

@karloyz Great that you like our project :-)
We just released https://github.com/itsallcode/holiday-calculator/releases/tag/0.2.1 with the fix.
It should be available on Maven Central soon: https://repo1.maven.org/maven2/org/itsallcode/holiday-calculator/0.2.1/

@ckunki
Copy link
Collaborator

ckunki commented Jul 7, 2024

Special credits to @kaklakariada for fixing the sonar setup and doing the release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants