Closed sunxyw closed 2 years ago
Won't be adding this feature myself anytime soon, however, if you can please make a PR!
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.
It will be great if you can add support for the
perWeek
interval.