-
Notifications
You must be signed in to change notification settings - Fork 47
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
RecurrenceRule returns wrong BYMONTH part value #98
Comments
Right, sounds like a bug indeed. Shouldn't be hard to fix though. I'll check that. |
After looking into the code again, it realized this was actually intended behaviour. RFC 5545 (and therefore RRULE) use 1-based month numbers, whereas Java's Calendar class (which served as the model for the implementation back then, when I started this) uses 0-based month numbers. |
Hi Marten. Thanks for response and for library! I think that you are right and in that case better to update an API so that rule.getByPart(RecurrenceRule.Part.BYMONTH) returns the same month number as configured in the original rule/string representation. |
Hi all~! |
Hi all. Recently I have found a strange behaviour that seems like a bug. When we build a RecurrentRule with BYMONTH part and then try to get the value of BYMONTH part from the result object via
rule.getByPart(RecurrenceRule.Part.BYMONTH)
- it returns the values that are reduced on 1. At the same time, if we will try to convert the object back to the RRULE string or calculate the next occurrence date - all is working correctly. As I can see, this happens because when GregorianCalendarMetrics parses BYMONTH for internal purposes it decrease the month and then increase back during serialization back to String. At the same time, from API point of view this seems confusing since I expect to receive always the correct values - both when get a particular part via direct method call or when convert to result String.The sample code to demonstrate the issue:
The output will look like:
As you can see, the calculated next date and the RRULE string contains the correct month - 11. But the rule.getByPart(RecurrenceRule.Part.BYMONTH) returns the value 10.
Is this an intended behaviour and is there any proper way to receive the correct value of the BYMONTH part?
Thanks!
The text was updated successfully, but these errors were encountered: