PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | sal/class.json-api-date.php +15 -10 12.7.316.3-a.1 View file →
@@ -3,8 +3,13 @@
3 3 * WPCOM_JSON_API_Date class.
4 4 *
5 5 * @package automattic/jetpack
6 6 */
7 +
8 +if ( ! defined( 'ABSPATH' ) ) {
9 + exit( 0 );
10 +}
11 +
7 12 /**
8 13 * Base class for WPCOM_JSON_API_Date.
9 14 */
10 15 class WPCOM_JSON_API_Date {
@@ -16,9 +21,9 @@
16 21 *
17 22 * @return string
18 23 */
19 24 public static function format_date( $date_gmt, $date = null ) {
20 - $offset = null;
25 + $offset = 0;
21 26 $timestamp_gmt = strtotime( "$date_gmt+0000" );
22 27
23 28 if ( null === $date ) {
24 29 $timestamp = $timestamp_gmt;
@@ -46,9 +51,9 @@
46 51 if ( $timezone ) {
47 52 $offset = $timezone->getOffset( $date_time );
48 53 }
49 54 } else {
50 - $offset = 3600 * get_option( 'gmt_offset' );
55 + $offset = 3600 * (float) get_option( 'gmt_offset' );
51 56 }
52 57 } else {
53 58 $offset = $timestamp - $timestamp_gmt;
54 59 }
@@ -59,9 +64,9 @@
59 64 $offset -= $hours * 3600;
60 65 $minutes = (int) floor( $offset / 60 );
61 66 }
62 67
63 - return (string) gmdate( 'Y-m-d\\TH:i:s', $timestamp ) . sprintf( '%s%02d:%02d', $west ? '-' : '+', $hours, $minutes );
68 + return gmdate( 'Y-m-d\\TH:i:s', $timestamp ) . sprintf( '%s%02d:%02d', $west ? '-' : '+', $hours, $minutes );
64 69 }
65 70
66 71 /**
67 72 * Returns ISO 8601 formatted duration interval: P0DT1H10M0S
@@ -77,18 +82,18 @@
77 82 if ( empty( $timestamp ) ) {
78 83 return;
79 84 }
80 85
81 - $days = floor( $timestamp / 86400 );
82 - $timestamp = $timestamp % 86400;
86 + $days = floor( $timestamp / 86400 );
87 + $timestamp %= 86400;
83 88
84 - $hours = floor( $timestamp / 3600 );
85 - $timestamp = $timestamp % 3600;
89 + $hours = floor( $timestamp / 3600 );
90 + $timestamp %= 3600;
86 91
87 - $minutes = floor( $timestamp / 60 );
88 - $timestamp = $timestamp % 60;
92 + $minutes = floor( $timestamp / 60 );
93 + $timestamp %= 60;
89 94
90 - return (string) sprintf(
95 + return sprintf(
91 96 'P%dDT%dH%dM%dS',
92 97 $days,
93 98 $hours,
94 99 $minutes,