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

Seasonal business days #21

Open
tomaszhanc opened this issue Oct 14, 2020 · 4 comments
Open

Seasonal business days #21

tomaszhanc opened this issue Oct 14, 2020 · 4 comments

Comments

@tomaszhanc
Copy link
Contributor

tomaszhanc commented Oct 14, 2020

I didn't find a way to create business hours for seasonal businesses. For example summer pub is opened every year from 1st of April to last of September. Maybe, I missed something and it's already possible. Anyway, @norberttech do you think it should be a part of aeon-php/business-hours or not?

@norberttech
Copy link
Member

This is exactly one of the scenarios I had in mind when working on this library and I believe it should be possible to achieve this already out of the box.

https://github.com/aeon-php/business-hours/blob/1.x/src/Aeon/Calendar/Gregorian/BusinessHours/NonBusinessDay/NonWorkingPeriod.php

Non Working Period receive TimePeriod which can be created for the current year that can be taken from Calendar.
In case that's not enough, you can always create a custom implementation of https://github.com/aeon-php/business-hours/blob/1.x/src/Aeon/Calendar/Gregorian/BusinessHours/NonBusinessDay.php

In case that won't work, please share some more details and I can try to prepare some pseudo-code maybe

@tomaszhanc
Copy link
Contributor Author

Making calculation for the given year are possible. I was thinking about the object which could represent a period without a year, eg: 1st of April to last of September. It means that I need a Day object without a year. I have no idea how to call it so let's call it for now as ugly as possible DayWithoutYear:

class DayWithoutYear
{
     private MonthWithoutYear $month;
     private int $day;
}

class PeriodWithoutYear
{
    private DayWithoutYear $after;
    private DayWithoutYear $before;

    public function in(Year $year) : TimePeriod { ... }
}

In my application I need to store period without the year because year will change. I'm not sure if such an object DayWithoutYear should be a part of the library or I should implement it on my own. I can imagine that I would need that in another project so it would be nice to have it somewhere to avoid copy-pasting.

@norberttech
Copy link
Member

Right, if closed season is repeatable and linear to avoid boilerplate code it might make sense to add something like ClosedSeason implementation of NonBusinessDay.
Any chance you could open pull request with this?

@tomaszhanc
Copy link
Contributor Author

Yeah, sure. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants