Skip to content

Commit

Permalink
Merge pull request #59 from SFDO-Community/feature/dec13-date-format-…
Browse files Browse the repository at this point in the history
…to-numeric

Update the date/time display logic for numeric display
  • Loading branch information
pickettd authored Dec 13, 2024
2 parents d3f49c8 + b2c4c78 commit 4bdb9c2
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,20 @@ function formatDateTimeLocale(dateStr, hasDate, hasTime) {
timeZone: TIMEZONE
};
if (hasDate) {
options.dateStyle = 'medium';
// Note that setting to short will have a 2-digit year, but we want 4 digit
//options.dateStyle = 'short';

options.year = 'numeric';
options.month = '2-digit';
options.day = '2-digit';
}
// If we leave default formatting (not setting date and time options) then time is not shown
if (hasTime) {
options.timeStyle = 'short';
// timeStyle short is the format we want, but since we need a 4 digit year, we need to set the time components manually
//options.timeStyle = 'short';

options.hour = '2-digit';
options.minute = '2-digit';
}
return new Intl.DateTimeFormat(LOCALE, options).format(new Date(dateStr));
}
Expand Down

0 comments on commit 4bdb9c2

Please sign in to comment.