PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 2.8.16
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v2.8.16
3.13.4 3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 All 262 releases
wpfunnels / packages / action-scheduler / classes / ActionScheduler_DateTime.php

ActionScheduler_DateTime.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 2.8.16, at packages/action-scheduler/classes/ActionScheduler_DateTime.php

77 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * ActionScheduler DateTime class.
5 *
6 * This is a custom extension to DateTime that
7 */
8 class ActionScheduler_DateTime extends DateTime {
9
10 /**
11 * UTC offset.
12 *
13 * Only used when a timezone is not set. When a timezone string is
14 * used, this will be set to 0.
15 *
16 * @var int
17 */
18 protected $utcOffset = 0;
19
20 /**
21 * Get the unix timestamp of the current object.
22 *
23 * Missing in PHP 5.2 so just here so it can be supported consistently.
24 *
25 * @return int
26 */
27 public function getTimestamp() {
28 return method_exists( 'DateTime', 'getTimestamp' ) ? parent::getTimestamp() : $this->format( 'U' );
29 }
30
31 /**
32 * Set the UTC offset.
33 *
34 * This represents a fixed offset instead of a timezone setting.
35 *
36 * @param $offset
37 */
38 public function setUtcOffset( $offset ) {
39 $this->utcOffset = intval( $offset );
40 }
41
42 /**
43 * Returns the timezone offset.
44 *
45 * @return int
46 * @link http://php.net/manual/en/datetime.getoffset.php
47 */
48 public function getOffset() {
49 return $this->utcOffset ? $this->utcOffset : parent::getOffset();
50 }
51
52 /**
53 * Set the TimeZone associated with the DateTime
54 *
55 * @param DateTimeZone $timezone
56 *
57 * @return static
58 * @link http://php.net/manual/en/datetime.settimezone.php
59 */
60 public function setTimezone( $timezone ) {
61 $this->utcOffset = 0;
62 parent::setTimezone( $timezone );
63
64 return $this;
65 }
66
67 /**
68 * Get the timestamp with the WordPress timezone offset added or subtracted.
69 *
70 * @since 3.0.0
71 * @return int
72 */
73 public function getOffsetTimestamp() {
74 return $this->getTimestamp() + $this->getOffset();
75 }
76 }
77