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 -9 12.0.3 → 16.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,8 +21,9 @@
16 21 *
17 22 * @return string
18 23 */
19 24 public static function format_date( $date_gmt, $date = null ) {
25 + $offset = 0;
20 26 $timestamp_gmt = strtotime( "$date_gmt+0000" );
21 27
22 28 if ( null === $date ) {
23 29 $timestamp = $timestamp_gmt;
@@ -45,9 +51,9 @@
45 51 if ( $timezone ) {
46 52 $offset = $timezone->getOffset( $date_time );
47 53 }
48 54 } else {
49 - $offset = 3600 * get_option( 'gmt_offset' );
55 + $offset = 3600 * (float) get_option( 'gmt_offset' );
50 56 }
51 57 } else {
52 58 $offset = $timestamp - $timestamp_gmt;
53 59 }
@@ -58,9 +64,9 @@
58 64 $offset -= $hours * 3600;
59 65 $minutes = (int) floor( $offset / 60 );
60 66 }
61 67
62 - 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 );
63 69 }
64 70
65 71 /**
66 72 * Returns ISO 8601 formatted duration interval: P0DT1H10M0S
@@ -76,18 +82,18 @@
76 82 if ( empty( $timestamp ) ) {
77 83 return;
78 84 }
79 85
80 - $days = floor( $timestamp / 86400 );
81 - $timestamp = $timestamp % 86400;
86 + $days = floor( $timestamp / 86400 );
87 + $timestamp %= 86400;
82 88
83 - $hours = floor( $timestamp / 3600 );
84 - $timestamp = $timestamp % 3600;
89 + $hours = floor( $timestamp / 3600 );
90 + $timestamp %= 3600;
85 91
86 - $minutes = floor( $timestamp / 60 );
87 - $timestamp = $timestamp % 60;
92 + $minutes = floor( $timestamp / 60 );
93 + $timestamp %= 60;
88 94
89 - return (string) sprintf(
95 + return sprintf(
90 96 'P%dDT%dH%dM%dS',
91 97 $days,
92 98 $hours,
93 99 $minutes,