From 907eb2893f331f5d9cda1f277d3dd3137deb0f50 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Tue, 28 Mar 2023 14:20:33 +0000 Subject: [PATCH] Date/Time: Revert [55054]. This changeset introduced a regression for partial-hour timezones such as +05:30 UTC which is India and Sri Lanka. How? These timezones are in float. The change made in [55054] type casted them to integer which dropped the decimal for the partial-hour, making the time inaccurate. For example, +05:30 UTC (India and Sri Lanka)'s `'gmt_offset'` is `5.5`, but with the changeset, it was changed to `5`. Reverting the changeset restores the original state of `current_time()` and thus resolves the regression. Props reputeinfosystems, Rarst, hellofromTonya, desrosj, audrasjb, sergeybiryukov, costdev, priethor, francina, nekojonez, codingchicken, cbringmann. See #57035. Fixes #57998. git-svn-id: https://develop.svn.wordpress.org/trunk@55598 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 17e5a7c2ea..1cd71b3f75 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -73,7 +73,7 @@ function mysql2date( $format, $date, $translate = true ) { function current_time( $type, $gmt = 0 ) { // Don't use non-GMT timestamp, unless you know the difference and really need to. if ( 'timestamp' === $type || 'U' === $type ) { - return $gmt ? time() : time() + ( (int) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); + return $gmt ? time() : time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); } if ( 'mysql' === $type ) {