Skip to content

Commit

Permalink
Refactor date normalization logic in FormDateInput to improve readabi…
Browse files Browse the repository at this point in the history
…lity
  • Loading branch information
b-l-i-n-d committed Jan 30, 2025
1 parent bab7794 commit 5a21049
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions assets/react/v3/shared/components/fields/FormDateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ const createFormatters = (wpLocale: string): Partial<Formatters> => {

const normalizeDateString = (date: string): string => {
const parts = date.split('-');
if (parts.length !== 3) return date; // Invalid format
if (parts.length !== 3) {
return date;
}

// Pad month and day to 2 digits
const year = parts[0];
const month = parts[1].padStart(2, '0');
const day = parts[2].padStart(2, '0');
Expand Down

0 comments on commit 5a21049

Please sign in to comment.