PluginProbe
PostNL for WooCommerce / 3.1.7
PostNL for WooCommerce v3.1.7
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 3.1.7, at includes/compatibility/class-wc-date-compatibility.php

77 lines 1.5 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 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
9
10 if ( ! class_exists( '\\WPO\\WC\\PostNL\\Compatibility\\WC_DateTime' ) ) :
11
12
13 /**
14 * WC Wrapper for PHP DateTime.
15 *
16 * @class WC_DateTime
17 * @since 3.0.0
18 * @package WooCommerce/Classes
19 * @category Class
20 * @author WooThemes
21 */
22 class WC_DateTime extends \DateTime {
23
24 /**
25 * Output an ISO 8601 date string in local timezone.
26 *
27 * @since 3.0.0
28 * @return string
29 */
30 public function __toString() {
31 return $this->format( DATE_ATOM );
32 }
33
34 /**
35 * Missing in PHP 5.2.
36 *
37 * @since 3.0.0
38 * @return int
39 */
40 public function getTimestamp() {
41 return method_exists( 'DateTime', 'getTimestamp' ) ? parent::getTimestamp() : $this->format( 'U' );
42 }
43
44 /**
45 * Get the timestamp with the WordPress timezone offset added or subtracted.
46 *
47 * @since 3.0.0
48 * @return int
49 */
50 public function getOffsetTimestamp() {
51 return $this->getTimestamp() + $this->getOffset();
52 }
53
54 /**
55 * Format a date based on the offset timestamp.
56 *
57 * @since 3.0.0
58 * @param string $format
59 * @return string
60 */
61 public function date( $format ) {
62 return gmdate( $format, $this->getOffsetTimestamp() );
63 }
64
65 /**
66 * Return a localised date based on offset timestamp. Wrapper for date_i18n function.
67 *
68 * @since 3.0.0
69 * @param string $format
70 * @return string
71 */
72 public function date_i18n( $format = 'Y-m-d' ) {
73 return date_i18n( $format, $this->getOffsetTimestamp() );
74 }
75 }
76
77 endif; // Class exists check