Fixing date format retrieval?

This commit is contained in:
Kumi 2021-11-13 14:59:13 +01:00
parent b650ead13d
commit 0229cd598b
2 changed files with 7 additions and 8 deletions

View file

@ -78,6 +78,6 @@ class LanguageChoiceView(View):
class LocaleVariableView(View):
def get(self, request, *args, **kwargs):
variables = {
"date_format": get_format('SHORT_DATE_FORMAT', use_l10n=True)
"date_format": get_format('SHORT_DATE_FORMAT', use_l10n=True).replace("Y", "yyyy")
}
return JsonResponse(variables)

View file

@ -2,16 +2,15 @@
"use strict";
$.get("/api/getvars/").done(function(data) {
var date_format = data["date_format"];
console.log("this");
var date_format = "d.m.yyyy";
$.get("/api/getvars/").done(function(data) {
date_format = data["date_format"];
});
$('.dpd1').each(function() {
console.log("that");
console.log(date_format);
var mindate = new Date($(this).attr("data-mindate"));
mindate = new Date(mindate.getFullYear(), mindate.getMonth(), mindate.getDate(), 0, 0, 0, 0)
@ -19,7 +18,7 @@
maxdate = new Date(maxdate.getFullYear(), maxdate.getMonth(), maxdate.getDate(), 0, 0, 0, 0)
var checkin = $(this).datepicker({
format: "d.m.Y",
format: date_format,
onRender: function(date) {
return ((date.valueOf() < mindate.valueOf()) || (date.valueOf() > maxdate.valueOf())) ? 'disabled' : '';
}
@ -29,4 +28,4 @@
});
})(jQuery);
})(jQuery);