Skip to content

Commit

Permalink
fix(kit): fix normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Belokopytov committed Oct 31, 2024
1 parent 2029a90 commit c7ae6b8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions projects/kit/src/lib/processors/normalize-date-preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function normalizeDatePreprocessor({
continue;
}

if (template && template.length === segment.length) {
if (template) {
if (isLastTemplateSegment) {
dateParts.push(segment);
dates.push(dateParts.join(dateSegmentsSeparator));
Expand All @@ -45,10 +45,12 @@ export function normalizeDatePreprocessor({
}
}

if (dates.length === 1 && timeParts.length > 0) {
newData = `${dates[0]}${dateTimeSeparator}${timeParts.join(':')}`;
} else if (dates.length === 2) {
newData = dates.join(rangeSeparator);
if (dates.length > 0 && dateParts.length === 0) {
if (timeParts.length > 0) {
newData = `${dates[0]}${dateTimeSeparator}${timeParts.join(':')}`;
} else {
newData = dates.join(rangeSeparator);
}
}

return {elementState, data: newData};
Expand Down

0 comments on commit c7ae6b8

Please sign in to comment.