From ce6fec682352b9287e7bb3c23aec55aaf2d9557b Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Sun, 21 Jan 2024 22:53:40 +0100 Subject: [PATCH] Fixed sleep tracking not working --- src/index.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/index.php b/src/index.php index f788ac3..e14cbec 100755 --- a/src/index.php +++ b/src/index.php @@ -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"); }