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
f292f6cc
Commit
f292f6cc
authored
Feb 18, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change time unit definition according to Georges comments
parent
7c3b8607
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
+17
-14
dream/plugins/TimeSupport.py
dream/plugins/TimeSupport.py
+17
-14
No files found.
dream/plugins/TimeSupport.py
View file @
f292f6cc
...
...
@@ -11,7 +11,22 @@ class TimeSupportMixin(object):
initialized
=
False
def
initializeTimeSupport
(
self
,
data
):
self
.
timeUnitPerDay
=
data
[
'general'
][
'timeUnitPerDay'
]
self
.
timeUnit
=
data
[
'general'
][
'timeUnit'
]
if
self
.
timeUnit
==
'minute'
:
self
.
timeUnitPerDay
=
24
*
60
elif
self
.
timeUnit
==
'hour'
:
self
.
timeUnitPerDay
=
24
elif
self
.
timeUnit
==
'day'
:
self
.
timeUnitPerDay
=
1
elif
self
.
timeUnit
==
'week'
:
self
.
timeUnitPerDay
=
1
/
7.
elif
self
.
timeUnit
==
'month'
:
self
.
timeUnitPerDay
=
1
/
30.
elif
self
.
timeUnit
==
'year'
:
self
.
timeUnitPerDay
=
1
/
360.
else
:
raise
ValueError
(
"Unsupported time unit %s"
%
self
.
timeUnit
)
self
.
dateFormat
=
data
[
'general'
].
get
(
'dateFormat'
,
'%Y/%m/%d %H:%M:%S'
)
# Convert simulation 0 time to real world time
self
.
now
=
datetime
.
strptime
(
data
[
'general'
][
'currentDate'
],
self
.
dateFormat
)
...
...
@@ -33,17 +48,5 @@ class TimeSupportMixin(object):
"""Return the time unit as text.
"""
assert
self
.
initialized
,
"initializeTimeSupport has not been called"
if
self
.
timeUnitPerDay
==
24
*
60
:
return
'minute'
if
self
.
timeUnitPerDay
==
24
:
return
'hour'
if
self
.
timeUnitPerDay
==
1
:
return
'day'
if
self
.
timeUnitPerDay
==
1
/
7.
:
return
'week'
if
self
.
timeUnitPerDay
==
1
/
30.
:
return
'month'
if
timeUnitPerDay
==
1
/
360.
:
return
'year'
raise
ValueError
(
"Unsupported time unit %s"
%
self
.
timeUnitPerDay
)
return
self
.
timeUnit
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