Merge pull request #1834 from chason/gametime_bugfix

Fixing bug in gametime module
This commit is contained in:
Griatch 2019-04-19 09:55:18 +02:00 committed by GitHub
commit 176307bbe6
2 changed files with 5 additions and 5 deletions

View file

@ -189,12 +189,13 @@ def real_seconds_until(sec=None, min=None, hour=None,
if projected <= current:
# We increase one unit of time depending on parameters
days_in_month = monthrange(s_year, s_month)[1]
days_in_year = sum(monthrange(s_year, m + 1)[1] for m in range(12))
if month is not None:
projected += timedelta(days=days_in_year)
projected = projected.replace(year=s_year+1)
elif day is not None:
projected += timedelta(days=days_in_month)
try:
projected = projected.replace(month=s_month+1)
except ValueError:
projected = projected.replace(month=1)
elif hour is not None:
projected += timedelta(days=1)
elif min is not None:

View file

@ -78,7 +78,6 @@ class TestGametime(TestCase):
self.assertAlmostEqual(gametime.real_seconds_until(day=17), 501120)
self.assertAlmostEqual(gametime.real_seconds_until(month=1), 4752000)
@unittest.expectedFailure
def test_real_seconds_until_leap_year(self):
self.assertAlmostEqual(gametime.real_seconds_until(month=3), 5788800)