Fixed sleep tracking not working

This commit is contained in:
Maximilian Giller 2024-01-21 22:53:40 +01:00
parent 790ed4a7ae
commit ce6fec6823

View file

@ -75,8 +75,13 @@ loadGivenParameters($activity);
storeActivity($activity);
// Handle sleep streak
$startingHour = (int) date("H");
if ($activity->title == "Sleeping" && $startingHour > 18) {
$tz = 'Europe/Berlin';
$timestamp = $activity->startTime;
$dt = new DateTime("now", new DateTimeZone($tz)); //first argument "must" be a string
$dt->setTimestamp($timestamp); //adjust the object to correct timestamp
$startingHour = (int) $dt->format('H');
if ($activity->template == "sleeping" && $startingHour > 18) {
markTodayAsSuccess("sleep");
}