@@ -5541,6 +5541,40 @@ describe("DatePicker", () => {
55415541 expect ( container . querySelector ( ".react-datepicker" ) ) . not . toBeNull ( ) ;
55425542 } ) ;
55435543
5544+ it ( "should apply holiday class to correct date regardless of timezone (issue #6105)" , ( ) => {
5545+ // This test verifies that holidays specified as ISO date strings (YYYY-MM-DD)
5546+ // are displayed on the correct date. The bug was that new Date("YYYY-MM-DD")
5547+ // parses as UTC midnight, causing dates to shift in western timezones.
5548+ const holidays = [ { date : "2024-01-15" , holidayName : "Test Holiday" } ] ;
5549+
5550+ const { container } = render (
5551+ < DatePicker
5552+ selected = { new Date ( 2024 , 0 , 15 ) } // January 15, 2024 in local time
5553+ onChange = { ( ) => { } }
5554+ holidays = { holidays }
5555+ inline
5556+ /> ,
5557+ ) ;
5558+
5559+ // Find the day element for January 15th and verify it has the holiday class
5560+ const jan15 = container . querySelector (
5561+ ".react-datepicker__day--015:not(.react-datepicker__day--outside-month)" ,
5562+ ) ;
5563+ expect ( jan15 ) . not . toBeNull ( ) ;
5564+ expect ( jan15 ?. classList . contains ( "react-datepicker__day--holidays" ) ) . toBe (
5565+ true ,
5566+ ) ;
5567+
5568+ // Verify January 14th does NOT have the holiday class (the bug would show it here)
5569+ const jan14 = container . querySelector (
5570+ ".react-datepicker__day--014:not(.react-datepicker__day--outside-month)" ,
5571+ ) ;
5572+ expect ( jan14 ) . not . toBeNull ( ) ;
5573+ expect ( jan14 ?. classList . contains ( "react-datepicker__day--holidays" ) ) . toBe (
5574+ false ,
5575+ ) ;
5576+ } ) ;
5577+
55445578 it ( "should handle deferFocusInput and cancelFocusInput" , ( ) => {
55455579 jest . useFakeTimers ( ) ;
55465580
0 commit comments