mtierltd / timetracker

GNU Affero General Public License v3.0
81 stars 27 forks source link

Goals do not count work log entries that start before Monday 11:00 AM #93

Open steglicd opened 3 years ago

steglicd commented 3 years ago

if I Add a goal with 40h / week and then add a record: Monday 09:00 - 17:00, then this record is not counted for that goal. Adding a record: 11:00 - 19:00 is counted as 8h for that goal.

This patch fixes the issue for me:

diff --git a/lib/Controller/AjaxController.php b/lib/Controller/AjaxController.php
index ef8c9e8..9b767cb 100644
--- a/lib/Controller/AjaxController.php
+++ b/lib/Controller/AjaxController.php
@@ -1176,7 +1176,8 @@ class AjaxController extends Controller {
                $year = $date->format("Y");
                $weekstartdt = new \DateTime();
                $weekstartdt->setISODate($year, $weeknumber);
-
+                $hours = 11;
+                $weekstartdt->sub(new \DateInterval("PT{$hours}H"));
                return $weekstartdt;
        }
        public function getStartOfMonth($timestamp){

seems like returned timestamp from a DateTime object which is configured by setISODate() is not set to 00:00 of that day. So weeks start at Monday 11:00 in my case (but I#m not sure if this is TimeZone related).

puthre commented 3 years ago

Yes, all the reporting done server side is in UTC. Individual times are converted in local timezone by the clients depending on their individual location (or timezone settings).