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