Skip to content

Commit b5b1f51

Browse files
committed
Better name for the TIME Formatter
1 parent 026725a commit b5b1f51

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/lib/components/date/FormattedDateTime.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE = Intl.DateTimeFormat('en-GB', {
5454
hour12: false,
5555
});
5656

57-
export const LONG_TERM_DATE_FORMATER = Intl.DateTimeFormat('en-CA', {
57+
/**
58+
* @description Year month day formatter, without time. Used for describing long term date.
59+
* @example 2025-01-01
60+
*/
61+
export const YEAR_MONTH_DAY_FORMATTER = Intl.DateTimeFormat('en-CA', {
5862
year: 'numeric',
5963
month: '2-digit',
6064
day: '2-digit',
@@ -72,7 +76,7 @@ type FormattedDateTimeProps = {
7276
| 'day-month-abbreviated-hour-minute-second'
7377
| 'long-date'
7478
| 'chart-date'
75-
| 'long-term-date';
79+
| 'year-month-day';
7680

7781
value: Date;
7882
};
@@ -205,8 +209,8 @@ export const FormattedDateTime = ({
205209
return <>{LONG_DATE_FORMATER.format(value)}</>;
206210
case 'chart-date':
207211
return <>{DAY_MONTH_FORMATER.format(value).replace(/[ ,]/g, '')}</>;
208-
case 'long-term-date':
209-
return <>{LONG_TERM_DATE_FORMATER.format(value)}</>;
212+
case 'year-month-day':
213+
return <>{YEAR_MONTH_DAY_FORMATTER.format(value)}</>;
210214
default:
211215
return <></>;
212216
}

src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Tooltip as TooltipComponent } from '../tooltip/Tooltip.component';
2323
import {
2424
DAY_MONTH_ABBREVIATED_HOUR_MINUTE,
2525
FormattedDateTime,
26-
LONG_TERM_DATE_FORMATER,
26+
YEAR_MONTH_DAY_FORMATTER,
2727
} from '../date/FormattedDateTime';
2828

2929
const LineTemporalChartWrapper = styled.div`
@@ -413,7 +413,7 @@ export function LineTimeSerieChart({
413413
return timeFormat === 'date-time'
414414
? DAY_MONTH_ABBREVIATED_HOUR_MINUTE.format(date).replace(',', '')
415415
: timeFormat === 'date'
416-
? LONG_TERM_DATE_FORMATER.format(date)
416+
? YEAR_MONTH_DAY_FORMATTER.format(date)
417417
: '';
418418
},
419419
[timeFormat],

0 commit comments

Comments
 (0)