On s'adapte aux formats de django pour récupérer les valeurs
This commit is contained in:
parent
9e37b9f0ae
commit
52f60be731
1 changed files with 6 additions and 4 deletions
10
shared/static/vendor/datetimepicker/picker.js
vendored
10
shared/static/vendor/datetimepicker/picker.js
vendored
|
@ -8,6 +8,9 @@ const _months = {
|
||||||
'en': ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
'en': ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formatDT_1 = /(?<day>\d{2})\/(?<month>\d{2})\/(?<year>\d{4}) (?<hour>\d{2}):(?<minutes>\d{2})(:\d\d)?/;
|
||||||
|
const formatDT_2 = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) (?<hour>\d{2}):(?<minutes>\d{2})(:\d\d)?/;
|
||||||
|
|
||||||
function zero(value) {
|
function zero(value) {
|
||||||
return value < 10 ? `0${value}` : `${value}`;
|
return value < 10 ? `0${value}` : `${value}`;
|
||||||
}
|
}
|
||||||
|
@ -246,17 +249,16 @@ class DateTimePicker {
|
||||||
lang: 'fr',
|
lang: 'fr',
|
||||||
}
|
}
|
||||||
|
|
||||||
static formatDT = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) (?<hour>\d{2}):(?<minutes>\d{2})/;
|
|
||||||
static formatD = /(?<year>\d{4})-(?<month>\d{1,2})-(?<day>\d{1,2})/;
|
static formatD = /(?<year>\d{4})-(?<month>\d{1,2})-(?<day>\d{1,2})/;
|
||||||
|
|
||||||
static parseDate(value) {
|
static parseDate(value) {
|
||||||
const _vals = DateTimePicker.formatDT.exec(value);
|
const _vals = formatDT_1.exec(value) || formatDT_2.exec(value);
|
||||||
return _vals === null ? undefined : new Date(_vals[1], _vals[2] - 1, _vals[3], _vals[4], _vals[5]);
|
return _vals === null ? undefined : new Date(_vals.groups.year, _vals.groups.month - 1, _vals.groups.day, _vals.groups.hour, _vals.groups.minutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static parseDay(value) {
|
static parseDay(value) {
|
||||||
const _vals = DateTimePicker.formatD.exec(value);
|
const _vals = DateTimePicker.formatD.exec(value);
|
||||||
return _vals === null ? undefined : new Date(_vals[1], _vals[2] - 1, _vals[3]);
|
return _vals === null ? undefined : new Date(_vals.groups.year, _vals.groups.month - 1, _vals.groups.day);
|
||||||
}
|
}
|
||||||
|
|
||||||
static dateValue(value) {
|
static dateValue(value) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue