in web/frontend/src/assets/hd-date/utils.ts [220:295]
export function convertDate(values: string, format: string[]): string[] {
const createdValues: string[] = [];
const letters = values.match(REGULAR_LETTERS);
const separator = values.match(/[\/,\-,\.,\\]/);
const arrayValues: string[] = values.match(/\d+/gi);
let count = 0;
for (let i = 0; i < format.length; i++) {
if (separator != null) {
if (format[0] === DateTimeFormat.yyyy || arrayValues[0].length === 4) {
if (
format[i] === DateTimeFormat.dd ||
format[i] === DateTimeFormat.MM ||
format[i] === DateTimeFormat.yyyy ||
format[i] === DateTimeFormat.yy
) {
createdValues.push(getValue(arrayValues, format[i]));
count++;
}
} else {
if (separator[0] === '.' || separator[0] === '-' || separator[0] === ',') {
if (format[i] === DateTimeFormat.dd) {
createdValues.push(arrayValues[0]);
count++;
} else if (format[i] === DateTimeFormat.MM) {
createdValues.push(arrayValues[1]);
count++;
} else if (format[i] === DateTimeFormat.yyyy) {
createdValues.push(getValue(arrayValues, format[i]));
count++;
} else if (format[i] === DateTimeFormat.yy) {
createdValues.push(arrayValues[2]);
count++;
}
} else {
if (
format[i] === DateTimeFormat.dd ||
format[i] === DateTimeFormat.MM ||
format[i] === DateTimeFormat.yyyy ||
format[i] === DateTimeFormat.yy
) {
createdValues.push(getValue(arrayValues, format[i]));
count++;
} else if (format[i] === DateTimeFormat.yy) {
createdValues.push(arrayValues[2]);
count++;
}
}
}
}
if (!isNaN(parseInt(arrayValues[count]))) {
if (format[i] === DateTimeFormat.HH) {
HOURS = parseInt(arrayValues[count]);
if (letters != null && letters[0] === 'PM') {
createdValues.push(correctHours(arrayValues[count], format[i]));
} else {
createdValues.push(arrayValues[count]);
}
count++;
} else if (format[i] === DateTimeFormat.hh) {
HOURS = parseInt(arrayValues[count]);
createdValues.push(correctHours(arrayValues[count], format[i]));
count++;
} else if (format[i] === DateTimeFormat.mm) {
createdValues.push(arrayValues[count]);
count++;
} else if (format[i] === DateTimeFormat.ss) {
createdValues.push(arrayValues[count]);
count++;
} else if (format[i].length === 3 || format[i].length === 6 || format[i].length === 9) {
createdValues.push(arrayValues[count].slice(0, format[i].length));
count++;
}
}
}
return createdValues;
}