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

Request: add perWeek interval #7

Closed
sunxyw opened this issue Feb 19, 2022 · 2 comments
Closed

Request: add perWeek interval #7

sunxyw opened this issue Feb 19, 2022 · 2 comments

Comments

@sunxyw
Copy link

sunxyw commented Feb 19, 2022

It will be great if you can add support for the perWeek interval.

@Larsklopstra
Copy link
Member

Won't be adding this feature myself anytime soon, however, if you can please make a PR!

@kurucu
Copy link

kurucu commented May 27, 2022

This would be easy, but it might be a breaking change.CarbonPeriod accepts text for interval, and would accept e.g. "7 days".
But, the way that it's currently coded, "interval" accepts any singular period and then appends it to "1 ". I think the cleanest way to make the change is have the library just accept any loose text and pass it straight to CarbonPeriod.

Then the preset methods would read e.g.:

public function perYear()
{
    $this->interval = '1 year';
}

public function perWeek()
{
    $this->interval = '7 days';
}

Alternative option would be some clunky code e.g. look for an integer in $this->interval and if its not found, then add a 1 in front. That way, interval() would still work with the current interface, and perWeek (like above) could still be implemented.

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

No branches or pull requests

3 participants