| 1 |
<?php |
| 2 |
namespace FakerPress; |
| 3 |
|
| 4 |
use FakerPress\ThirdParty\Cake\Chronos\Chronos; |
| 5 |
|
| 6 |
Class Dates { |
| 7 |
|
| 8 |
public static function get_intervals(){ |
| 9 |
return apply_filters( |
| 10 |
'fakerpress/date.get_intervals', |
| 11 |
[ |
| 12 |
[ |
| 13 |
'id' => 'today', |
| 14 |
'text' => esc_attr__( 'Today', 'fakerpress' ), |
| 15 |
'min' => Chronos::today()->toDateString(), |
| 16 |
'max' => Chronos::today()->toDateString(), |
| 17 |
], |
| 18 |
[ |
| 19 |
'id' => 'yesterday', |
| 20 |
'text' => esc_attr__( 'Yesterday', 'fakerpress' ), |
| 21 |
'min' => Chronos::yesterday()->toDateString(), |
| 22 |
'max' => Chronos::yesterday()->toDateString(), |
| 23 |
], |
| 24 |
[ |
| 25 |
'id' => 'tomorrow', |
| 26 |
'text' => esc_attr__( 'Tomorrow', 'fakerpress' ), |
| 27 |
'min' => Chronos::tomorrow()->toDateString(), |
| 28 |
'max' => Chronos::tomorrow()->toDateString(), |
| 29 |
], |
| 30 |
[ |
| 31 |
'id' => 'this week', |
| 32 |
'text' => esc_attr__( 'This week', 'fakerpress' ), |
| 33 |
'min' => ( Chronos::today()->dayOfWeek === 1 ? Chronos::today()->toDateString() : Chronos::parse( 'last monday' )->toDateString() ), |
| 34 |
'max' => ( Chronos::today()->dayOfWeek === 0 ? Chronos::today()->toDateString() : Chronos::parse( 'next sunday' )->toDateString() ), |
| 35 |
], |
| 36 |
[ |
| 37 |
'id' => 'this month', |
| 38 |
'text' => esc_attr__( 'This month', 'fakerpress' ), |
| 39 |
'min' => Chronos::today()->day( 1 )->toDateString(), |
| 40 |
'max' => Chronos::parse( 'last day of this month' )->toDateString(), |
| 41 |
], |
| 42 |
[ |
| 43 |
'id' => 'this year', |
| 44 |
'text' => esc_attr__( 'This year', 'fakerpress' ), |
| 45 |
'min' => Chronos::today()->day( 1 )->month( 1 )->toDateString(), |
| 46 |
'max' => Chronos::parse( 'last day of december' )->toDateString(), |
| 47 |
], |
| 48 |
[ |
| 49 |
'id' => 'last 15 days', |
| 50 |
'text' => esc_attr__( 'Last 15 days', 'fakerpress' ), |
| 51 |
'min' => Chronos::today()->subDays( 15 )->toDateString(), |
| 52 |
'max' => Chronos::today()->toDateString(), |
| 53 |
], |
| 54 |
[ |
| 55 |
'id' => 'next 15 days', |
| 56 |
'text' => esc_attr__( 'Next 15 Days', 'fakerpress' ), |
| 57 |
'min' => Chronos::today()->toDateString(), |
| 58 |
'max' => Chronos::today()->addDays( 15 )->toDateString(), |
| 59 |
], |
| 60 |
] |
| 61 |
); |
| 62 |
} |
| 63 |
|
| 64 |
} |
| 65 |
|