resolved timezones

This commit is contained in:
Čarodej
2022-02-06 14:26:42 +01:00
parent 38e86b4b8b
commit 21e184f373
10 changed files with 37 additions and 54 deletions

View File

@@ -580,16 +580,12 @@ if (! function_exists('filter_folders_ids')) {
if (! function_exists('format_date')) {
/**
* Format localized date
*
* @param $date
* @param string $format
* @return string
*/
function format_date($date, $format = '%d. %B. %Y, %H:%M')
function format_date($date, string $format = 'd. M. Y, h:i'): string
{
$start = Carbon::parse($date);
return $start->formatLocalized($format);
return $start->translatedFormat($format);
}
}
@@ -949,17 +945,13 @@ if (! function_exists('set_time_by_user_timezone')) {
/**
* Set time by user timezone GMT
*/
function set_time_by_user_timezone(string $time): string | Carbon
function set_time_by_user_timezone($user, $createdAt): string | Carbon
{
$user = Auth::user();
$timezone = $user->settings->timezone ?? 0;
if ($user) {
$time_zone = $user->settings->timezone ?? 0;
return Carbon::parse($time)->addMinutes($time_zone * 60);
}
return $time;
return Carbon::parse($createdAt)
->addMinutes($timezone * 60)
->translatedFormat('d. M. Y, h:i');
}
}