-
Notifications
You must be signed in to change notification settings - Fork 30
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
WorkingHours.return_to_working_time() doesn't pass .in_working_hours?
#28
Comments
Maybe this needs a hack like |
Interesting, but tricky to do well, as it must not interfere with, for example: It also must not break the iteration pattern present in The behavior you want looks logical but is not really IMO, as ranges in computer science are often defined by one inclusive end and one exclusive for a reason: it's more precise. Imagine someone who doesn't care about seconds or minutes and just want to know if a given hour is in his business time, returning true for the end of the range would be a 1 hour long mistake. So I don't think this is worth the trouble implementing for the general case (and I'm pretty sure we'll get people asking for the opposite then) What I can offer you is to add an option to the |
I realize it's tricky, which is why I filed a bug report and not a PR ;) I agree that your use case of 'is 17:00 a working hour' is reasonable, but I also think if I'm asking to be returned to the last working time, then I should be given a time that's within working hours, not one outside... otherwise, you're breaking the contract of Whether the range is an open or closed range is irrelevant... that's implementation detail to me as a user of the module. All I want to make sure is if I have asked to be returned to working hours, I am indeed within those hours. |
I see, then maybe we should rename this method, and have another one with this name returning an offseted time to be inside the period ? |
That seems like a reasonable way forward w/out messing up what the internals expect when walking the time list. |
Ok, can you do that @Intrepidd ? |
Yup whenever I got a chance |
Any idea on the naming ?
I'll keep |
My suggestion is keeping |
Why not but in this case we must bump the major version number as this is a
|
Or maybe |
When one returns a time to working time, it would seem sensible that the time actually passes the
.in_working_hours?
test in all cases.However, if the time passed to
return_to_working_time
was outside working hours to start with, thenWorkingHours.return_to_working_time
will return a time that does not pass the.in_working_hours?
predicate (because it returns the exact closing time).See for example:
The text was updated successfully, but these errors were encountered: