Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
3c4f71bb
Commit
3c4f71bb
authored
Oct 22, 2013
by
Alexander Kryklia
Committed by
polesye
Oct 23, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update variable names and fix typo.
parent
ab5653d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
common/lib/xmodule/xmodule/fields.py
+8
-8
No files found.
common/lib/xmodule/xmodule/fields.py
View file @
3c4f71bb
...
...
@@ -196,7 +196,7 @@ class RelativeTime(Field):
if
isinstance
(
value
,
float
):
# backward compatibility
if
value
>
86400
:
value
=
86400
return
self
.
_str
(
datetime
.
timedelta
(
seconds
=
value
))
return
self
.
timedelta_to_string
(
datetime
.
timedelta
(
seconds
=
value
))
if
isinstance
(
value
,
datetime
.
timedelta
):
if
value
.
total_seconds
()
>
86400
:
# sanity check
...
...
@@ -204,18 +204,18 @@ class RelativeTime(Field):
"RelativeTime max value is 23:59:59=86400.0 seconds, "
"but {} seconds is passed"
.
format
(
value
.
total_seconds
())
)
return
self
.
_str
(
value
)
return
self
.
timedelta_to_string
(
value
)
raise
TypeError
(
"RelativeTime: cannot convert {!r} to json"
.
format
(
value
))
def
_str
(
self
,
value
):
def
timedelta_to_string
(
self
,
value
):
"""
Makes first 'H' in str representation non-optional.
str(timedelta) has [H]H:MM:SS format, which is not suitable
for front-end (and I
soTime standart), so we fors
e HH:MM:SS format.
for front-end (and I
SO time standard), so we forc
e HH:MM:SS format.
"""
string
=
str
(
value
)
if
len
(
string
)
==
7
:
string
=
'0'
+
string
return
string
string
ified
=
str
(
value
)
if
len
(
string
ified
)
==
7
:
string
ified
=
'0'
+
stringified
return
string
ified
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