Commit 7e04278a authored by Georgios Dagkakis's avatar Georgios Dagkakis

comment cleanup and allow second as time unit in TimeSupport

parent 19a573e6
......@@ -12,7 +12,9 @@ class TimeSupportMixin(object):
def initializeTimeSupport(self, data):
self.timeUnit = data['general']['timeUnit']
if self.timeUnit == 'minute':
if self.timeUnit == 'second':
self.timeUnitPerDay = 24 * 60 * 60
elif self.timeUnit == 'minute':
self.timeUnitPerDay = 24 * 60
elif self.timeUnit == 'hour':
self.timeUnitPerDay = 24
......@@ -42,12 +44,8 @@ class TimeSupportMixin(object):
"""Convert real world time (as python datetime object) to simulation clock time.
"""
assert self.initialized, "initializeTimeSupport has not been called"
# XXX (real_world_time - self.now).total_seconds() gives seconds
# we want to convert this to our units (minutes in batches, but generally).
# if our time unit was seconds, the timeUnitPerDay would be 24 * 60 *60 = 86400
# so we need to divide with 86400/self.timeUnitPerDay I think. If we have minutes it works
# if we had hours it would be self.timeUnitPerDay = 24, 86400/24=3600, which is what we need to divide a num of secs
# to produce hours
# get the seconds difference and divide by (24*60*60/self.timeUnitPerDay)
# 24*60*60 is timeUnitPerDay if the unit is seconds
return (real_world_time - self.now).total_seconds()/(86400/self.timeUnitPerDay)
def getTimeUnitText(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment