Here are the codes I used:
Code: Select all
init python:
import datetime
class GameTime(object):
def __init__(self, dt="Jan 01 2018"):
self._dt = datetime.datetime.strptime( dt, "%d %b %Y" )
def alter(self, **kwargs):
if not kwargs:
kwargs = {'hours':6}
self._dt += datetime.timedelta( **kwargs )
def __repr__(self):
return _strftime("%A", self._dt.timetuple())
@property
def period(self):
return [ k[-1] for k in (
(0,1,2,3,4,5, "Morning"),
(6,7,8,9,10,11, "Noon"),
(12,13,14,15,16,17, "Evening"),
(18,19,20,21,22,23, "Night") ) if self._dt.hour in k ][0]
default gt = GameTime("24 Sep 2018")
Code: Select all
menu time_loop:
"Today is [gt], it is [gt.period]."
"Next period.":
$ gt.alter()
jump time_loop
"Next day.":
"Is it morning yet?"
$ gt.alter( days=1, hours=-gt._dt.hour)
jump time_loop
"Break Loop":
pass