Parse date period
adaojunior opened this issue · comments
Issue summary
I think it would be interesting if this library would permite parse from string eg: Period::parse("last week")
.
Inspired by: Carbon
@adaojunior since I can already do this
<?php
use Carbon\Carbon;
use League\Period\Period;
$period = new Period(Carbon::parse("last week"), Carbon::parse("next week"));
I don't see the benefit of adding the feature to this library
I've been using Carbon in the way you just described and I found that it may be limited. I'm using it on a Laravel console eg:
I wish I could use this:
php artisan some-report "last week"
But I ended up with:
php artisan some-report "last week|next week"
I think the first one is a better alternative, I actually started some work to support this. I may release it as a package and you you find it useful you can integrate into this library as well.
I've been using Carbon in the way you just described and I found that it may be limited.
Whatever you do, you will always end up having to instantiate a Period object with your datepoints. How you come up with your datepoints is up to you and your script/business logic. The package will never cover every business logic in this regards