Skip to content

Commit

Permalink
[frontend] Adapt datetime picker placeholders to date format
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreDoneux committed Feb 27, 2024
1 parent 18bf00e commit bf06893
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion inginious/frontend/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,26 @@
var timezone = "{{user_manager.session_timezone()}}" !== "None" ? "{{user_manager.session_timezone()}}" : Intl.DateTimeFormat().resolvedOptions().timeZone;
js_datetime_format = "{{available_datetime_formats[user_manager.session_datetime_format()]}}";

// Update datetime display
$(".datetime-display").each(function() {
var date = $(this).text();

// check the date has a correct structure
if (moment(date, 'YYYY-MM-DD HH:mm:ss.SSSSS').isValid()) {
var updatedDate = moment.utc(date, 'YYYY-MM-DD HH:mm:ss.SSSSS').tz(timezone).format(js_datetime_format);
$(this).text(updatedDate);
}
});

// Update datetime input placeholder to correct format
$(".datetimepicker-input").each(function() {
var date = $(this).attr('placeholder');

if (moment(date, 'YYYY-MM-DD HH:mm:ss.SSSSS').isValid()) {
var updatedDate = moment.utc(date, 'YYYY-MM-DD HH:mm:ss').format(js_datetime_format);
$(this).attr('placeholder', updatedDate);
}
});

});

</script>
Expand Down

0 comments on commit bf06893

Please sign in to comment.