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
Hourly.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP_SCOPED\IAWP\Statistics\Intervals; |
| 4 | |
| 5 | /** @internal */ |
| 6 | class Hourly extends Interval |
| 7 | { |
| 8 | public function id() : string |
| 9 | { |
| 10 | return 'hourly'; |
| 11 | } |
| 12 | public function label() : string |
| 13 | { |
| 14 | return \__('Hourly', 'independent-analytics'); |
| 15 | } |
| 16 | public function date_interval() : \DateInterval |
| 17 | { |
| 18 | return new \DateInterval('PT1H'); |
| 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->setTime(\intval($date_time->format('G')), 0, 0); |
| 24 | return $date_time; |
| 25 | } |
| 26 | public function get_label_for(\DateTime $date_time) : array |
| 27 | { |
| 28 | $date_format = 'F jS'; |
| 29 | $time_format = \get_option('time_format', 'g:i a'); |
| 30 | $in_one_hour = (clone $date_time)->add(new \DateInterval('PT1H')); |
| 31 | return ['tick' => $this->format($date_time, $time_format), 'tooltipLabel' => $this->format($date_time, $time_format) . " - " . $this->format($in_one_hour, $time_format) . $this->format($date_time, ' (' . $date_format . ')')]; |
| 32 | } |
| 33 | } |
| 34 |