-
Notifications
You must be signed in to change notification settings - Fork 168
Cookbook example showing how to do Hijri days adjustments (without custom calendar) #2912
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the example!
You had some questions, I'll try to answer them here:
with the exception of toPlainYearMonth and toPlainMonthDay that exist in all the Temporal objects aforementioned. the rest of toX functions are not implemented here and would like to hear your thoughts on how the implementation would look like. for example how would toZonedDateTime behave on a ZonedDateTime underlying object.
If you don't need them directly, I'd consider leaving them out. If you do need them, then I'd suggest to decide first whether e.g. toZonedDateTime
should return Temporal.ZonedDateTime or AdjustableHijriTemporal with underlying ZonedDateTime. I could imagine good reasons for either one.
The question of how would toZonedDateTime
behave on a ZonedDateTime underlying object, I'd say it depends on your use case. It could return the same object or it could throw.
from and fromX where not implemented because of the same complexity mentioned above. but if there is an agreement on how they should behave I can proceed with the implementation.
Same, if you don't need them directly, I'd consider leaving them out. I'd say this example is meant as a starting point for readers to customize for their own use cases, not as an API specification that they must implement. The AdjustableHijriTemporal constructor seems pretty comprehensive to me; if you want to construct an AdjustableHijriTemporal object from a string or property bag, there's always the option of new AdjustableHijriTemporal(Temporal.PlainDate.from(...), ...)
.
If readers need a from()
method that behaves differently, they can write it according to their use cases, or simplify the problem by splitting AdjustableHijriTemporal into separate PlainDate/PlainDateTime/ZonedDateTime classes, or whatever.
d819b06
to
f147bdf
Compare
Thanks for finishing up the description page. The one thing missing was a link from the main cookbook page. I've added this and will merge it now. |
This PR implements the
AdjustableHijriTemporal
class for customizing Hijri date display.This class allows for adjustment of Hijri dates by shifting days forward or backward. It's designed to:
Key points:
Notes to maintainers: The implementation uses composition instead of inheritance and I have made it so that one class can accommodate for
PlainDate
,PlainDateTime
andZonedDateTime
as such the class doesn't implement the following functions:toPlainYearMonth
andtoPlainMonthDay
that exist in all the Temporal objects aforementioned. the rest of toX functions are not implemented here and would like to hear your thoughts on how the implementation would look like. for example how wouldtoZonedDateTime
behave on aZonedDateTime
underlying object.from
andfromX
where not implemented because of the same complexity mentioned above. but if there is an agreement on how they should behave I can proceed with the implementation.