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
988833de
Commit
988833de
authored
Sep 12, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pylint/pep8
parent
95ad1826
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
14 deletions
+13
-14
common/lib/xmodule/xmodule/tests/test_date_utils.py
+2
-2
common/lib/xmodule/xmodule/util/date_utils.py
+11
-11
lms/djangoapps/courseware/tests/test_views.py
+0
-1
No files found.
common/lib/xmodule/xmodule/tests/test_date_utils.py
View file @
988833de
...
...
@@ -14,14 +14,14 @@ def test_get_default_time_display():
get_default_time_display
(
test_time
))
def
test_get_d
efault_time_display
_notz
():
def
test_get_d
flt_time_disp
_notz
():
test_time
=
datetime
(
1992
,
3
,
12
,
15
,
3
,
30
)
assert_equals
(
"Mar 12, 1992 at 15:03 UTC"
,
get_default_time_display
(
test_time
))
def
test_get_time_disp
lay_return
_empty
():
def
test_get_time_disp
_ret
_empty
():
assert_equals
(
""
,
get_time_display
(
None
))
test_time
=
datetime
(
1992
,
3
,
12
,
15
,
3
,
30
,
tzinfo
=
UTC
)
assert_equals
(
""
,
get_time_display
(
test_time
,
""
))
...
...
common/lib/xmodule/xmodule/util/date_utils.py
View file @
988833de
...
...
@@ -4,7 +4,7 @@ Convenience methods for working with datetime objects
from
datetime
import
timedelta
def
get_default_time_display
(
dt
):
def
get_default_time_display
(
dt
ime
):
"""
Converts a datetime to a string representation. This is the default
representation used in Studio and LMS.
...
...
@@ -12,20 +12,20 @@ def get_default_time_display(dt):
If None is passed in for dt, an empty string will be returned.
"""
if
dt
is
None
:
if
dt
ime
is
None
:
return
u""
if
dt
.
tzinfo
is
not
None
:
if
dt
ime
.
tzinfo
is
not
None
:
try
:
timezone
=
u" "
+
dt
.
tzinfo
.
tzname
(
dt
)
timezone
=
u" "
+
dt
ime
.
tzinfo
.
tzname
(
dtime
)
except
NotImplementedError
:
timezone
=
dt
.
strftime
(
'
%
z'
)
timezone
=
dt
ime
.
strftime
(
'
%
z'
)
else
:
timezone
=
u" UTC"
return
unicode
(
dt
.
strftime
(
u"
%
b
%
d,
%
Y at
%
H:
%
M{tz}"
))
.
format
(
return
unicode
(
dt
ime
.
strftime
(
u"
%
b
%
d,
%
Y at
%
H:
%
M{tz}"
))
.
format
(
tz
=
timezone
)
.
strip
()
def
get_time_display
(
dt
,
format_string
=
None
):
def
get_time_display
(
dt
ime
,
format_string
=
None
):
"""
Converts a datetime to a string representation.
...
...
@@ -36,12 +36,12 @@ def get_time_display(dt, format_string=None):
format_string should be a unicode string that is a valid argument for datetime's strftime method.
"""
if
dt
is
None
or
format_string
is
None
:
return
get_default_time_display
(
dt
)
if
dt
ime
is
None
or
format_string
is
None
:
return
get_default_time_display
(
dt
ime
)
try
:
return
unicode
(
dt
.
strftime
(
format_string
))
return
unicode
(
dt
ime
.
strftime
(
format_string
))
except
ValueError
:
return
get_default_time_display
(
dt
)
return
get_default_time_display
(
dt
ime
)
def
almost_same_datetime
(
dt1
,
dt2
,
allowed_delta
=
timedelta
(
minutes
=
1
)):
...
...
lms/djangoapps/courseware/tests/test_views.py
View file @
988833de
...
...
@@ -317,4 +317,3 @@ class ViewsTestCase(TestCase):
text
=
set_due_date_format
(
u"
%%%
"
)
self
.
assertNotIn
(
"
%%%
"
,
text
)
self
.
assertIn
(
time_with_utc
,
text
)
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