def test_split_time(self): # Sunrise. self.assertEqual(split_time(0), (6, 0)) # Noon. self.assertEqual(split_time(6000), (12, 0)) # Sunset. self.assertEqual(split_time(12000), (18, 0)) # Midnight. self.assertEqual(split_time(18000), (0, 0))
def dispatch(self, factory): hours, minutes = split_time(factory.time) # Check if the world has seasons enabled seasons = retrieve_plugins(ISeason).values() if seasons: season = factory.world.season day_of_season = factory.day - season.day while day_of_season < 0: day_of_season += 360 date = "{0} ({1} {2})".format(factory.day, day_of_season, season.name) else: date = "%d" % factory.day yield "%02d:%02d, %s" % (hours, minutes, date)
def dispatch(self, factory): hours, minutes = split_time(factory.time) # If the factory's got seasons enabled, then the world will have # a season, and we can examine it. Otherwise, just print the day as-is # for the date. season = factory.world.season if season: day_of_season = factory.day - season.day while day_of_season < 0: day_of_season += 360 date = "{0} ({1} {2})".format(factory.day, day_of_season, season.name) else: date = "%d" % factory.day return ("%02d:%02d, %s" % (hours, minutes, date),)
def dispatch(self, factory): hours, minutes = split_time(factory.time) # If the factory's got seasons enabled, then the world will have # a season, and we can examine it. Otherwise, just print the day as-is # for the date. season = factory.world.season if season: day_of_season = factory.day - season.day while day_of_season < 0: day_of_season += 360 date = "{0} ({1} {2})".format(factory.day, day_of_season, season.name) else: date = "%d" % factory.day return ("%02d:%02d, %s" % (hours, minutes, date), )