PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / trunk
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment vtrunk
3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 122 releases
firebox / Inc / Core / Analytics / Helpers / Date.php

Date.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment trunk, at Inc/Core/Analytics/Helpers/Date.php

96 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 3.1.13 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2026 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\Analytics\Helpers;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class Date
20 {
21 public static function isSingleDay($start_date = null, $end_date = null)
22 {
23 if (!$start_date || !$end_date)
24 {
25 return false;
26 }
27
28 if (!\DateTime::createFromFormat('Y/m/d H:i:s', $start_date) || !\DateTime::createFromFormat('Y/m/d H:i:s', $end_date))
29 {
30 return false;
31 }
32
33 $start_date = new \DateTime($start_date);
34 $end_date = new \DateTime($end_date);
35
36 $interval = $start_date->diff($end_date);
37 $totalDays = (int) $interval->format('%a');
38
39 return $totalDays === 0;
40 }
41
42 public static function fixTimezoneInHourlyData($data = [])
43 {
44 if (!is_array($data))
45 {
46 return $data;
47 }
48
49 $utcTimeZone = new \DateTimeZone('UTC');
50 $tz = new \DateTimeZone(wp_timezone()->getName());
51
52 foreach ($data as &$item)
53 {
54 if (!isset($item->label))
55 {
56 continue;
57 }
58
59 if (!$item->label)
60 {
61 continue;
62 }
63
64 if (!$dateTime = \DateTime::createFromFormat('H:i', $item->label, $utcTimeZone))
65 {
66 continue;
67 }
68
69 $dateTime->setTimezone($tz);
70
71 $item->label = $dateTime->format('H:i');
72 }
73
74 return $data;
75 }
76
77 public static function transformStartEndDateToUTC(&$start_date = '', &$end_date = '')
78 {
79 $utcTimeZone = new \DateTimeZone('UTC');
80 $tz = new \DateTimeZone(wp_timezone()->getName());
81
82 // Make start in UTC
83 if ($start_date_obj = \DateTime::createFromFormat('Y/m/d H:i:s', $start_date, $tz))
84 {
85 $start_date_obj->setTimezone($utcTimeZone);
86 $start_date = $start_date_obj->format('Y/m/d H:i:s');
87 }
88
89 // Make end_date in UTC
90 if ($end_date_obj = \DateTime::createFromFormat('Y/m/d H:i:s', $end_date, $tz))
91 {
92 $end_date_obj->setTimezone($utcTimeZone);
93 $end_date = $end_date_obj->format('Y/m/d H:i:s');
94 }
95 }
96 }