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