File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,27 +32,29 @@ const getYPos = (hours: number | string) => {
3232 return { rem : `${ rem } rem` , px }
3333}
3434
35+ const formatDate = ( date : string ) =>
36+ getLocale ( ) === "iso"
37+ ? date
38+ : new Date ( date ) . toLocaleDateString ( getLocale ( ) , {
39+ day : "2-digit" ,
40+ month : "2-digit" ,
41+ year : "numeric" ,
42+ } )
43+
44+ const getDayName = ( date : string ) =>
45+ new Date ( date ) . toLocaleDateString ( getLocale ( ) , {
46+ weekday : "long" ,
47+ } )
48+
3549const CalendarHeader = ( { dates } : { dates : string [ ] } ) => (
3650 < div className = { cn ( hstack ( ) , "pb-4 pl-8" ) } >
37- { dates . map ( dateString => {
38- const date = new Date ( dateString )
39- return (
40- < div
41- key = { dateString }
42- className = "grid flex-1 place-content-center text-center"
43- >
44- { date . toLocaleDateString ( getLocale ( ) , { weekday : "long" } ) }
45- < br />
46- < span className = "text-xs text-text-muted" >
47- { date . toLocaleDateString ( getLocale ( ) , {
48- day : "2-digit" ,
49- month : "2-digit" ,
50- year : "numeric" ,
51- } ) }
52- </ span >
53- </ div >
54- )
55- } ) }
51+ { dates . map ( date => (
52+ < div key = { date } className = "grid flex-1 place-content-center text-center" >
53+ { getDayName ( date ) }
54+ < br />
55+ < span className = "text-xs text-text-muted" > { formatDate ( date ) } </ span >
56+ </ div >
57+ ) ) }
5658 </ div >
5759)
5860
You can’t perform that action at this time.
0 commit comments