From ee5675ef5b5755dc1a06f5b3e237dd40d33356ac Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 5 Sep 2018 20:21:30 +1000 Subject: [PATCH] days since creation needs to be calculated relative to rollover https://anki.tenderapp.com/discussions/ankidesktop/29502-next-day-starts-experimental-v2-scheduler-bug --- anki/schedv2.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/anki/schedv2.py b/anki/schedv2.py index 95b935945..c223e1ca9 100644 --- a/anki/schedv2.py +++ b/anki/schedv2.py @@ -1196,7 +1196,7 @@ where id = ? def _updateCutoff(self): oldToday = self.today # days since col created - self.today = int((time.time() - self.col.crt) // 86400) + self.today = self._daysSinceCreation() # end of day cutoff self.dayCutoff = self._dayCutoff() if oldToday != self.today: @@ -1233,6 +1233,12 @@ where id = ? stamp = time.mktime(date.timetuple()) return stamp + def _daysSinceCreation(self): + startDate = datetime.datetime.fromtimestamp(self.col.crt) + startDate = startDate.replace(hour=self.col.conf.get("rollover", 4), + minute=0, second=0, microsecond=0) + return (time.time() - time.mktime(startDate.timetuple())) // 86400 + # Deck finished state ##########################################################################