Daily.php
2 years ago
Hourly.php
2 years ago
Interval.php
2 years ago
Intervals.php
2 years ago
Monthly.php
2 years ago
Weekly.php
2 years ago
Monthly.php
32 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP_SCOPED\IAWP\Statistics\Intervals; |
| 4 | |
| 5 | /** @internal */ |
| 6 | class Monthly extends Interval |
| 7 | { |
| 8 | public function id() : string |
| 9 | { |
| 10 | return 'monthly'; |
| 11 | } |
| 12 | public function label() : string |
| 13 | { |
| 14 | return \__('Monthly', 'independent-analytics'); |
| 15 | } |
| 16 | public function date_interval() : \DateInterval |
| 17 | { |
| 18 | return new \DateInterval('P01M'); |
| 19 | } |
| 20 | public function calculate_start_of_interval_for(\DateTime $original_date_time) : \DateTime |
| 21 | { |
| 22 | $date_time = clone $original_date_time; |
| 23 | $date_time->setDate(\intval($date_time->format('Y')), \intval($date_time->format('m')), 1); |
| 24 | $date_time->setTime(0, 0, 0); |
| 25 | return $date_time; |
| 26 | } |
| 27 | public function get_label_for(\DateTime $date_time) : array |
| 28 | { |
| 29 | return ['tick' => $this->format($date_time, 'F'), 'tooltipLabel' => $this->format($date_time, 'F')]; |
| 30 | } |
| 31 | } |
| 32 |