diff --git a/lms/static/js/dateutil_factory.js b/lms/static/js/dateutil_factory.js index 4e75636c5a..fea79f1d9e 100644 --- a/lms/static/js/dateutil_factory.js +++ b/lms/static/js/dateutil_factory.js @@ -28,16 +28,29 @@ var displayDatetime; var isValid; var transform; + var dueDateFormat; + var dateFormat; + + dueDateFormat = Object.freeze({ + '%Y-%d-%m': 'YYYY, D MMM HH[:]mm z', // example: 2018, 01 Jan 15:30 UTC + '%m-%d-%Y': 'MMM D, YYYY HH[:]mm z', // example: Jan 01, 2018 15:30 UTC + '%d-%m-%Y': 'D MMM YYYY HH[:]mm z', // example: 01 Jan, 2018 15:30 UTC + '%Y-%m-%d': 'YYYY, MMM D HH[:]mm z' // example: 2018, Jan 01 15:30 UTC + }); transform = function(iterationKey) { var context; $(iterationKey).each(function() { if (isValid($(this).data('datetime'))) { + dateFormat = DateUtils.dateFormatEnum[$(this).data('format')]; + if (typeof dateFormat === 'undefined') { + dateFormat = dueDateFormat[$(this).data('format')]; + } context = { datetime: $(this).data('datetime'), timezone: $(this).data('timezone'), language: $(this).data('language'), - format: DateUtils.dateFormatEnum[$(this).data('format')] + format: dateFormat }; displayDatetime = stringHandler( localizedTime(context), diff --git a/openedx/features/course_experience/templates/course_experience/course-outline-fragment-new.html b/openedx/features/course_experience/templates/course_experience/course-outline-fragment-new.html index 5fa0a0d8b2..d20f17deae 100644 --- a/openedx/features/course_experience/templates/course_experience/course-outline-fragment-new.html +++ b/openedx/features/course_experience/templates/course_experience/course-outline-fragment-new.html @@ -112,6 +112,7 @@ from openedx.core.djangolib.markup import HTML, Text class="localized-datetime subtitle-name" data-datetime="${subsection.get('due')}" data-string="${data_string}" + data-format= "${due_date_display_format}" data-timezone="${user_timezone}" data-language="${user_language}" > @@ -122,6 +123,7 @@ from openedx.core.djangolib.markup import HTML, Text