Fixed issue with daylight saving time in chart

This commit is contained in:
Constantin Graf
2024-10-30 17:40:46 +01:00
parent 04fcc1e3ae
commit f4cfeaa718

View File

@@ -47,22 +47,24 @@ class DashboardService
{
$result = [];
$windowSize = 24 / $windows;
$end = Carbon::now($timeZone)->endOfDay()->subHours(3)->utc()->toDateTimeString();
$end = Carbon::now($timeZone)->startOfDay()->addDay()->subHours(3)->utc()->toDateTimeString();
$start = Carbon::now($timeZone)->subDays($days)->startOfDay()->utc()->toDateTimeString();
$date = Carbon::now($timeZone)->startOfDay();
$dateUtc = Carbon::now($timeZone)->startOfDay()->utc();
for ($i = 0; $i < $days; $i++) {
$dateString = $date->format('Y-m-d');
$tempDate = $date->copy();
$tempDate = $dateUtc->copy();
$start = $tempDate->copy()->utc()->toDateTimeString();
$tempWindows = [];
for ($j = 0; $j < $windows; $j++) {
$tempWindow = $tempDate->utc()->toDateTimeString();
$tempWindow = $tempDate->toDateTimeString();
$tempWindows[] = $tempWindow;
$tempDate->addHours($windowSize);
}
$result[$dateString] = $tempWindows;
$date->subDay();
$dateUtc->subDay();
}
return [