Bugfix
The date($year, $month, $day) function is intended to construct a date (in system time). However, the function returns a value where the time part is set to the current time. This is unexpected and unfavorable if you want to compare the value with other date values.
Test
E.g. date(2024, 7, 5).toSystemCalendar().hour() == 0