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
be170060
Commit
be170060
authored
Feb 14, 2014
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use strftime_localized for dates.
parent
64db0e78
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
common/djangoapps/util/date_utils.py
+12
-4
i18n/dummy.py
+6
-0
No files found.
common/djangoapps/util/date_utils.py
View file @
be170060
...
@@ -13,9 +13,12 @@ def get_default_time_display(dtime):
...
@@ -13,9 +13,12 @@ def get_default_time_display(dtime):
"""
"""
Converts a datetime to a string representation. This is the default
Converts a datetime to a string representation. This is the default
representation used in Studio and LMS.
representation used in Studio and LMS.
It is of the form "Apr 09, 2013 at 16:00 UTC".
It will use the "DATE_TIME" format in the current language, if provided,
or defaults to "Apr 09, 2013 at 16:00 UTC".
If None is passed in for dt, an empty string will be returned.
If None is passed in for dt, an empty string will be returned.
"""
"""
if
dtime
is
None
:
if
dtime
is
None
:
return
u""
return
u""
...
@@ -26,8 +29,9 @@ def get_default_time_display(dtime):
...
@@ -26,8 +29,9 @@ def get_default_time_display(dtime):
timezone
=
dtime
.
strftime
(
'
%
z'
)
timezone
=
dtime
.
strftime
(
'
%
z'
)
else
:
else
:
timezone
=
u" UTC"
timezone
=
u" UTC"
return
unicode
(
dtime
.
strftime
(
u"
%
b
%
d,
%
Y at
%
H:
%
M{tz}"
))
.
format
(
tz
=
timezone
)
.
strip
()
localized
=
strftime_localized
(
dtime
,
"DATE_TIME"
)
return
(
localized
+
timezone
)
.
strip
()
def
get_time_display
(
dtime
,
format_string
=
None
,
coerce_tz
=
None
):
def
get_time_display
(
dtime
,
format_string
=
None
,
coerce_tz
=
None
):
...
@@ -53,7 +57,7 @@ def get_time_display(dtime, format_string=None, coerce_tz=None):
...
@@ -53,7 +57,7 @@ def get_time_display(dtime, format_string=None, coerce_tz=None):
if
dtime
is
None
or
format_string
is
None
:
if
dtime
is
None
or
format_string
is
None
:
return
get_default_time_display
(
dtime
)
return
get_default_time_display
(
dtime
)
try
:
try
:
return
unicode
(
dtime
.
strftime
(
format_string
))
return
unicode
(
strftime_localized
(
dtime
,
format_string
))
except
ValueError
:
except
ValueError
:
return
get_default_time_display
(
dtime
)
return
get_default_time_display
(
dtime
)
...
@@ -363,3 +367,7 @@ MONTHS = {
...
@@ -363,3 +367,7 @@ MONTHS = {
# date-time formats. See http://strftime.org for details.
# date-time formats. See http://strftime.org for details.
12
:
pgettext
(
'month name'
,
'December'
),
12
:
pgettext
(
'month name'
,
'December'
),
}
}
# Now that we are done defining constants, we have to restore the real pgettext
# so that the functions in this module will have the right definition.
pgettext
=
real_pgettext
i18n/dummy.py
View file @
be170060
...
@@ -23,7 +23,9 @@ generates output conf/locale/$DUMMY_LOCALE/LC_MESSAGES,
...
@@ -23,7 +23,9 @@ generates output conf/locale/$DUMMY_LOCALE/LC_MESSAGES,
where $DUMMY_LOCALE is the dummy_locale value set in the i18n config
where $DUMMY_LOCALE is the dummy_locale value set in the i18n config
"""
"""
import
re
import
sys
import
sys
import
polib
import
polib
from
path
import
path
from
path
import
path
...
@@ -173,6 +175,10 @@ def make_dummy(filename, locale, converter):
...
@@ -173,6 +175,10 @@ def make_dummy(filename, locale, converter):
raise
IOError
(
'File does not exist:
%
r'
%
filename
)
raise
IOError
(
'File does not exist:
%
r'
%
filename
)
pofile
=
polib
.
pofile
(
filename
)
pofile
=
polib
.
pofile
(
filename
)
for
msg
in
pofile
:
for
msg
in
pofile
:
# Some strings are actually formatting strings, don't dummy-ify them,
# or dates will look like "DÀTÉ_TÌMÉ_FÖRMÀT Ⱡ'σ# EST"
if
re
.
match
(
r"^[A-Z_]+_FORMAT$"
,
msg
.
msgid
):
continue
converter
.
convert_msg
(
msg
)
converter
.
convert_msg
(
msg
)
# Apply declaration for English pluralization rules so that ngettext will
# Apply declaration for English pluralization rules so that ngettext will
...
...
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