-
Notifications
You must be signed in to change notification settings - Fork 230
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
Consider a Holiday class #79
Conversation
--HG-- extra : amend_source : e2b1f36319875798bf21deb3075deab65f9ea230
--HG-- extra : rebase_source : d0ec2a68e9565aaa015984de775b07df1d263189
…_HOLIDAYS to contain Holiday entries.
--HG-- extra : amend_source : f15d243f1146ebf29f8970f2e3159be9265df632
First of all, thanks for you PR. It triggers a lot of thinking, which is good. If the workalendar rendered calendar is sent as a tuple (date + string as a label), that was because it was simple. No extra class, only using standard-lib types, etc. Your Holiday class looks interesting, but there's at least one issue to me: the "weekend_hint" which looks like a "mandatory" behaviour. AFAICT not every calendar is using this "shift to the next monday" strategy. In France, for example, if a holiday happens on sunday or saturday, it's not shifted. Let's imagine there's a calendar with 8-day-long weeks. This argument will be very difficult to handle in this Holiday object... This triggers me one bigger thought: that you're hiding the "shift / do not shift" logic in the Holiday class. Again, I'm quite pleased by your take on the Holiday class, but it bears too much logic to me. I'm sure this class can be simplified, and I'd gladly integrate it into workalendar... Even if it causes me to migrate every other calendar to use it as an output object for calendar rendering. |
Excellent. I completely agree with your assessment. The weekend shift behavior was an artifact of a simplistic (single-calendar) implementation from which I drew. Giving the shift behavior some calendar-context seems like the right thing to do. Here's the reason that the shift behavior was written into the Holiday class - our company has calendars which include adjacent, floating holidays, such as Christmas and Christmas Eve. When one or both of those holidays lands on a weekend, it's important how the observed date is calculated. As it turned out, the earlier date is always observed on Friday and the latter date always observed on Monday. The calendar itself doesn't know which way to shift an observed Holiday, so it needed a hint. I'll continue to refine the implementation, encouraged by your conditional endorsement. Thanks. |
…vance dates reflected in each result.
…t for relativedelta addition)
…ame', similar to the original two-tuple. 'indication' and 'weekend_hint' are now optional arguments as are any additional keyword arguments used in construction.
--HG-- extra : amend_source : 8ecc724430c4ea14fdc35f99b014d23c2fff75d1
…ich the default is now defined in the Calendar class.
--HG-- extra : amend_source : f8b6166e815bd352874ac388f7450d4fec93df85
@brunobord I struggled with how to transition from my previous implementation to something that worked better within the calendar model, but I'm pleased to say I'm much happier with this latest implementation, and I think you will be too. It completely abstracts the shift for observation date from the Holiday class (though provides one small hook so the observation shift can be overridden by the holiday). Now the calendar is aware of the indicated holidays ( I would like to make more changes, but I've been striving to maintain backward compatibility as much as possible. If at some point you want to remove the ability for holidays to be defined as two-tuples, much of the compatibility code goes away. |
Will the project consider accepting these changes? They're essential to our use-case and provide a good deal of additional value with minimal imposition. |
--HG-- extra : amend_source : 3cc9be7eb9bb69645bc3c17a987e4cd3cffeb577
Hi, I have deeply thought about your PR and I've come to this conclusion: I still think that workalendar should keep as lightweight as possible. This is why (and I feel sorry because I think you've worked hard on this feature) your pull-request won't be merged into master. Again, thank you for your PR proposal, and I wish you don't keep hard feelings on this project. |
Hi. I'm disappointed in this choice. What dismays me the most is that it's unclear what the stance is of workalendar on the issues that this PR addresses (#76, #77, and #78). Will the project attempt to solve those issues in a different way? Particularly when it comes to the issues of duplicate entries and reflecting the indicated vs. observed dates for Holidays, the calendar as implemented is not adequate. My goal in using workalendar was to merge the very similar work we were both doing to achieve both of our goals through a single library. I will consider your suggestion to create a separate wrapper library, but that approach seems riddled with problems:
I also was considering further extending workalendar to support non-working days of other types (sick leave, vacation, etc), but if the intention of the project is to limit innovation to a certain scope that only uses simple types for anything except Calendar objects, it's unlikely that will happen either. Given that workalendar is deciding to limit its scope of development, I'm inclined to think that a fork of the project would be preferable. Since it is your project, I respect your decision. |
The implementation of this Holiday class enables an individual calendar implementer to more accurately describe each holiday using a first-class object. These changes demonstrate how the use of such a class gives more flexibility about the definition of each holiday, including when it is observed.
As a result, this fixes (or provides a mechanism to fix) #76, #77, and #78.
As much as possible, these changes attempt to maintain backward compatibility, but it's plausible that some users will find the changes incompatible with their customizations.
All the tests pass (on Python 3 at least).
I'm not necessarily requesting that these changes be merged as-is, but I did want to collect these changes as a concrete proposal for consideration and discussion. Accepting changes like these would be essential for me to adopt workalendar for my application.
I look forward to your feedback.