Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
7e04278a
Commit
7e04278a
authored
Feb 20, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comment cleanup and allow second as time unit in TimeSupport
parent
19a573e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
dream/plugins/TimeSupport.py
dream/plugins/TimeSupport.py
+5
-7
No files found.
dream/plugins/TimeSupport.py
View file @
7e04278a
...
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment