Skip to content

Commit 04d83ed

Browse files
matthewpidanny6167
andcommitted
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 pterodactyl#4821 Superseeds pterodactyl#4827 Co-authored-by: danny6167 <[email protected]>
1 parent 1586061 commit 04d83ed

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

app/Helpers/Time.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ final class Time
1515
*/
1616
public static function getMySQLTimezoneOffset(string $timezone): string
1717
{
18-
$offset = round(CarbonImmutable::now($timezone)->getTimezone()->getOffset(CarbonImmutable::now('UTC')) / 3600);
19-
20-
return sprintf('%s%s:00', $offset > 0 ? '+' : '-', str_pad((string) abs($offset), 2, '0', STR_PAD_LEFT));
18+
return CarbonImmutable::now($timezone)->getTimezone()->toOffsetName();
2119
}
2220
}

0 commit comments

Comments
 (0)