Add unittests for contrib/chargen and custom_gametime. Removed unused time units settings from custom_gametime.

This commit is contained in:
Griatch 2017-02-19 13:10:17 +01:00
parent 7e395ea7ec
commit 46a5a62d2b
4 changed files with 137 additions and 96 deletions

View file

@ -68,6 +68,7 @@ Installation/testing:
"""
from __future__ import division
import datetime
import re
from django.conf import settings
from evennia import DefaultRoom
@ -129,12 +130,12 @@ class ExtendedRoom(DefaultRoom):
"""
Calculate the current time and season ids.
"""
# get the current time as parts of year and parts of day
# returns a tuple (years,months,weeks,days,hours,minutes,sec)
time = gametime.gametime(format=True)
month, hour = time[1], time[4]
season = float(month) / MONTHS_PER_YEAR
timeslot = float(hour) / HOURS_PER_DAY
# get the current time as parts of year and parts of day.
# we assume a standard calendar here and use 24h format.
timestamp = gametime.gametime(absolute=True)
datestamp = datetime.datetime.fromtimestamp(timestamp)
season = float(datestamp.month) / MONTHS_PER_YEAR
timeslot = float(datestamp.hour) / HOURS_PER_DAY
# figure out which slots these represent
if SEASONAL_BOUNDARIES[0] <= season < SEASONAL_BOUNDARIES[1]: