thibaud-dauce / period-presenter
There is no license information available for the latest version (v1.0.0) of this package.
Present a period in a human readable format
v1.0.0
2017-10-31 11:06 UTC
Requires
- nesbot/carbon: ^1.22
- thibaud-dauce/pattern-matching: ^1.0
Requires (Dev)
- phpunit/phpunit: ^6.4
This package is auto-updated.
Last update: 2024-12-04 16:41:29 UTC
README
Present a period in a human readable format. Works only in french right now. I'm open to Pull Requests.
Installation
composer require thibaud-dauce/period-presenter
setlocale(LC_TIME, 'fr_FR.utf8');
Usage
Single month
$period = new PeriodPresenter(
Carbon::parse('2017-02-01'),
Carbon::parse('2017-03-01')
);
$this->assertEquals('février 2017', $period->present());
Two months
$period = new PeriodPresenter(
Carbon::parse('2017-02-01'),
Carbon::parse('2017-04-01')
);
$this->assertEquals('février 2017 et mars 2017', $period->present());
More than two months
$period = new PeriodPresenter(
Carbon::parse('2017-02-01'),
Carbon::parse('2017-05-01')
);
$this->assertEquals('de février 2017 à avril 2017', $period->present());
Less than one month
$period = new PeriodPresenter(
Carbon::parse('2017-02-15'),
Carbon::parse('2017-03-01')
);
$this->assertEquals('du 15 février 2017 au 1 mars 2017', $period->present());