app: fix getMySQLTimezoneOffset() truncating seconds

Previously the `getMySQLTimezoneOffset()` function would truncate the
seconds part of a time offset (returning `+9:00` instead of `+9:30`) for
example. This only affects timezones with offsets that contain minutes.

Closes https://github.com/pterodactyl/panel/issues/4821
Superseeds https://github.com/pterodactyl/panel/pull/4827

Co-authored-by: danny6167 <daniel@barteck.com.au>
This commit is contained in:
Matthew Penner 2023-08-22 18:52:13 -06:00
parent 15860613b6
commit 04d83edd36
No known key found for this signature in database

View file

@ -15,8 +15,6 @@ final class Time
*/
public static function getMySQLTimezoneOffset(string $timezone): string
{
$offset = round(CarbonImmutable::now($timezone)->getTimezone()->getOffset(CarbonImmutable::now('UTC')) / 3600);
return sprintf('%s%s:00', $offset > 0 ? '+' : '-', str_pad((string) abs($offset), 2, '0', STR_PAD_LEFT));
return CarbonImmutable::now($timezone)->getTimezone()->toOffsetName();
}
}