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
5a8e4bff
Commit
5a8e4bff
authored
Jun 07, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test all date_utils variants
parent
e4757452
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletions
+35
-1
common/lib/xmodule/xmodule/tests/test_date_utils.py
+34
-0
common/lib/xmodule/xmodule/util/date_utils.py
+1
-1
No files found.
common/lib/xmodule/xmodule/tests/test_date_utils.py
View file @
5a8e4bff
...
...
@@ -18,3 +18,37 @@ def test_get_default_time_display():
assert_equals
(
"Mar 12, 1992 at 15:03"
,
date_utils
.
get_default_time_display
(
test_time
,
False
))
def
test_get_default_time_display_notz
():
test_time
=
datetime
.
datetime
(
1992
,
3
,
12
,
15
,
3
,
30
)
assert_equals
(
"Mar 12, 1992 at 15:03 UTC"
,
date_utils
.
get_default_time_display
(
test_time
))
assert_equals
(
"Mar 12, 1992 at 15:03 UTC"
,
date_utils
.
get_default_time_display
(
test_time
,
True
))
assert_equals
(
"Mar 12, 1992 at 15:03"
,
date_utils
.
get_default_time_display
(
test_time
,
False
))
# pylint: disable=W0232
class
NamelessTZ
(
datetime
.
tzinfo
):
def
utcoffset
(
self
,
_dt
):
return
datetime
.
timedelta
(
hours
=-
3
)
def
dst
(
self
,
_dt
):
return
datetime
.
timedelta
(
0
)
def
test_get_default_time_display_no_tzname
():
assert_equals
(
""
,
date_utils
.
get_default_time_display
(
None
))
test_time
=
datetime
.
datetime
(
1992
,
3
,
12
,
15
,
3
,
30
,
tzinfo
=
NamelessTZ
())
assert_equals
(
"Mar 12, 1992 at 15:03-0300"
,
date_utils
.
get_default_time_display
(
test_time
))
assert_equals
(
"Mar 12, 1992 at 15:03-0300"
,
date_utils
.
get_default_time_display
(
test_time
,
True
))
assert_equals
(
"Mar 12, 1992 at 15:03"
,
date_utils
.
get_default_time_display
(
test_time
,
False
))
common/lib/xmodule/xmodule/util/date_utils.py
View file @
5a8e4bff
...
...
@@ -16,7 +16,7 @@ def get_default_time_display(dt, show_timezone=True):
try
:
timezone
=
" "
+
dt
.
tzinfo
.
tzname
(
dt
)
except
NotImplementedError
:
timezone
=
" UTC"
timezone
=
dt
.
strftime
(
'
%
z'
)
else
:
timezone
=
" UTC"
return
dt
.
strftime
(
"
%
b
%
d,
%
Y at
%
H:
%
M"
)
+
timezone
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