Merge pull request #380 from edx/db/studio-i18n

Studio internationalization
This commit is contained in:
David Baumgold
2013-07-13 05:45:50 -07:00
47 changed files with 602 additions and 563 deletions

View File

@@ -5,7 +5,6 @@ from lxml import etree
from path import path # NOTE (THK): Only used for detecting presence of syllabus
import requests
from datetime import datetime
import dateutil.parser
from xmodule.modulestore import Location

View File

@@ -1,8 +1,10 @@
"""
Convenience methods for working with datetime objects
"""
from datetime import timedelta
from django.utils.translation import ugettext as _
import datetime
def get_default_time_display(dt, show_timezone=True):
"""
Converts a datetime to a string representation. This is the default
@@ -14,20 +16,21 @@ def get_default_time_display(dt, show_timezone=True):
The default value of show_timezone is True.
"""
if dt is None:
return ""
timezone = ""
return u""
timezone = u""
if show_timezone:
if dt.tzinfo is not None:
try:
timezone = " " + dt.tzinfo.tzname(dt)
timezone = u" " + dt.tzinfo.tzname(dt)
except NotImplementedError:
timezone = dt.strftime('%z')
else:
timezone = " UTC"
return dt.strftime("%b %d, %Y at %H:%M") + timezone
timezone = u" UTC"
return unicode(dt.strftime(u"%b %d, %Y {at} %H:%M{tz}")).format(
at=_(u"at"), tz=timezone).strip()
def almost_same_datetime(dt1, dt2, allowed_delta=datetime.timedelta(minutes=1)):
def almost_same_datetime(dt1, dt2, allowed_delta=timedelta(minutes=1)):
"""
Returns true if these are w/in a minute of each other. (in case secs saved to db
or timezone aren't same)