1- export function formatDate ( date ) {
1+ export function formatDate ( date , locale ) {
22 const now = new Date ( ) ;
33
44 // normalize to local midnight for date-only comparison
@@ -8,15 +8,15 @@ export function formatDate(date) {
88
99 // Today: show just time
1010 if ( diffDays === 0 ) {
11- return date . toLocaleTimeString ( undefined , {
11+ return date . toLocaleTimeString ( locale , {
1212 hour : "numeric" ,
1313 minute : "2-digit"
1414 } ) ;
1515 }
1616
1717 // Yesterday: show "Yesterday, <time>"
1818 if ( diffDays === 1 ) {
19- const time = date . toLocaleTimeString ( undefined , {
19+ const time = date . toLocaleTimeString ( locale , {
2020 hour : "numeric" ,
2121 minute : "2-digit"
2222 } ) ;
@@ -26,7 +26,7 @@ export function formatDate(date) {
2626 // Otherwise: full date + time, omit year if same
2727 const sameYear = date . getFullYear ( ) === now . getFullYear ( ) ;
2828
29- return date . toLocaleString ( undefined , {
29+ return date . toLocaleString ( locale , {
3030 year : sameYear ? undefined : "numeric" ,
3131 month : "short" ,
3232 day : "numeric" ,
@@ -35,8 +35,8 @@ export function formatDate(date) {
3535 } ) ;
3636}
3737
38- export function formatFullDate ( date ) {
39- return date . toLocaleString ( undefined , {
38+ export function formatFullDate ( date , locale ) {
39+ return date . toLocaleString ( locale , {
4040 year : "numeric" ,
4141 month : "short" ,
4242 day : "numeric" ,
0 commit comments