PluginProbe
Independent Analytics – WordPress Analytics Plugin / 2.1.5
Independent Analytics – WordPress Analytics Plugin v2.1.5
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 All 120 releases
independent-analytics / IAWP / Statistics / Intervals / Hourly.php
Hourly.php
34 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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