File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -69,10 +69,18 @@ const formatDate = (dateStr: string, endDateStr?: string): string => {
6969 month : "long" ,
7070 day : "numeric" ,
7171 } ;
72- const startDate = new Date ( dateStr ) . toLocaleDateString ( "en-US" , options ) ;
72+
73+ // Parse as local date to avoid timezone issues
74+ // (new Date("YYYY-MM-DD") parses as UTC, causing off-by-one day errors in some timezones)
75+ const parseLocalDate = ( str : string ) : Date => {
76+ const [ year , month , day ] = str . split ( "-" ) . map ( Number ) ;
77+ return new Date ( year , month - 1 , day ) ;
78+ } ;
79+
80+ const startDate = parseLocalDate ( dateStr ) . toLocaleDateString ( "en-US" , options ) ;
7381
7482 if ( endDateStr ) {
75- const endDate = new Date ( endDateStr ) . toLocaleDateString ( "en-US" , options ) ;
83+ const endDate = parseLocalDate ( endDateStr ) . toLocaleDateString ( "en-US" , options ) ;
7684 return `${ startDate } - ${ endDate } ` ;
7785 }
7886
You can’t perform that action at this time.
0 commit comments