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
26377a57
Commit
26377a57
authored
Apr 20, 2016
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue with pre-1900 course setting dates (TNL-4397)
parent
bb5874d5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
cms/djangoapps/contentstore/tests/test_course_settings.py
+12
-0
common/lib/xmodule/xmodule/fields.py
+4
-0
No files found.
cms/djangoapps/contentstore/tests/test_course_settings.py
View file @
26377a57
...
@@ -52,6 +52,18 @@ class CourseSettingsEncoderTest(CourseTestCase):
...
@@ -52,6 +52,18 @@ class CourseSettingsEncoderTest(CourseTestCase):
self
.
assertIsNone
(
jsondetails
[
'effort'
],
"effort somehow initialized"
)
self
.
assertIsNone
(
jsondetails
[
'effort'
],
"effort somehow initialized"
)
self
.
assertIsNone
(
jsondetails
[
'language'
],
"language somehow initialized"
)
self
.
assertIsNone
(
jsondetails
[
'language'
],
"language somehow initialized"
)
def
test_pre_1900_date
(
self
):
"""
Tests that the encoder can handle a pre-1900 date, since strftime
doesn't work for these dates.
"""
details
=
CourseDetails
.
fetch
(
self
.
course
.
id
)
pre_1900
=
datetime
.
datetime
(
1564
,
4
,
23
,
1
,
1
,
1
,
tzinfo
=
UTC
())
details
.
enrollment_start
=
pre_1900
dumped_jsondetails
=
json
.
dumps
(
details
,
cls
=
CourseSettingsEncoder
)
loaded_jsondetails
=
json
.
loads
(
dumped_jsondetails
)
self
.
assertEqual
(
loaded_jsondetails
[
'enrollment_start'
],
pre_1900
.
isoformat
())
def
test_ooc_encoder
(
self
):
def
test_ooc_encoder
(
self
):
"""
"""
Test the encoder out of its original constrained purpose to see if it functions for general use
Test the encoder out of its original constrained purpose to see if it functions for general use
...
...
common/lib/xmodule/xmodule/fields.py
View file @
26377a57
...
@@ -73,6 +73,10 @@ class Date(JSONField):
...
@@ -73,6 +73,10 @@ class Date(JSONField):
return
time
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
SZ'
,
value
)
return
time
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
SZ'
,
value
)
elif
isinstance
(
value
,
datetime
.
datetime
):
elif
isinstance
(
value
,
datetime
.
datetime
):
if
value
.
tzinfo
is
None
or
value
.
utcoffset
()
.
total_seconds
()
==
0
:
if
value
.
tzinfo
is
None
or
value
.
utcoffset
()
.
total_seconds
()
==
0
:
if
value
.
year
<
1900
:
# strftime doesn't work for pre-1900 dates, so use
# isoformat instead
return
value
.
isoformat
()
# isoformat adds +00:00 rather than Z
# isoformat adds +00:00 rather than Z
return
value
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
SZ'
)
return
value
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
SZ'
)
else
:
else
:
...
...
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