PluginProbe
PostNL for WooCommerce / 4.4.0
PostNL for WooCommerce v4.4.0
5.9.12 5.9.11 5.9.10 5.9.9 5.9.8 5.9.7 5.9.6 trunk 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.1.4 3.1.5 3.1.6 3.1.7 4.0.0 4.0.1 4.0.2 4.3.2 4.3.3 4.4.0 4.4.1 All 72 releases
woo-postnl / includes / compatibility / class-wc-date-compatibility.php

class-wc-date-compatibility.php in PostNL for WooCommerce 4.4.0, at includes/compatibility/class-wc-date-compatibility.php

89 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Copy of WC3.0 WC_DateTime class
4 */
5
6 namespace WPO\WC\PostNL\Compatibility;
7
8 use DateTime;
9
10 if (!defined('ABSPATH')) {
11 exit;
12 } // Exit if accessed directly
13
14 if (class_exists('\\WPO\\WC\\PostNL\\Compatibility\\WC_DateTime')) {
15 return;
16 }
17
18 /**
19 * WC Wrapper for PHP DateTime.
20 *
21 * @class WC_DateTime
22 * @category Class
23 * @package WooCommerce/Classes
24 * @author WooThemes
25 * @since 3.0.0
26 */
27 class WC_DateTime extends DateTime
28 {
29
30 /**
31 * Output an ISO 8601 date string in local timezone.
32 *
33 * @return string
34 * @since 3.0.0
35 */
36 public function __toString()
37 {
38 return $this->format(DATE_ATOM);
39 }
40
41 /**
42 * Missing in PHP 5.2.
43 *
44 * @return int
45 * @since 3.0.0
46 */
47 public function getTimestamp()
48 {
49 return method_exists('DateTime', 'getTimestamp') ? parent::getTimestamp() : $this->format('U');
50 }
51
52 /**
53 * Get the timestamp with the WordPress timezone offset added or subtracted.
54 *
55 * @return int
56 * @since 3.0.0
57 */
58 public function getOffsetTimestamp()
59 {
60 return $this->getTimestamp() + $this->getOffset();
61 }
62
63 /**
64 * Format a date based on the offset timestamp.
65 *
66 * @param string $format
67 *
68 * @return string
69 * @since 3.0.0
70 */
71 public function date($format)
72 {
73 return gmdate($format, $this->getOffsetTimestamp());
74 }
75
76 /**
77 * Return a localised date based on offset timestamp. Wrapper for date_i18n function.
78 *
79 * @param string $format
80 *
81 * @return string
82 * @since 3.0.0
83 */
84 public function date_i18n($format = 'Y-m-d')
85 {
86 return date_i18n($format, $this->getOffsetTimestamp());
87 }
88 }
89