bdlukaa / fluent_ui

Implements Microsoft's WinUI3 in Flutter.
https://bdlukaa.github.io/fluent_ui/
BSD 3-Clause "New" or "Revised" License
2.91k stars 453 forks source link

🐛 Wrong number of days for a month in `DatePicker` #1049

Closed matthiasnunn closed 2 months ago

matthiasnunn commented 6 months ago

Describe the bug March 2024 has only 30 days instead of 31 days in DatePicker.

To Reproduce See the demo page:

Bildschirmfoto 2024-04-01 um 13 01 27

Additional context The problem occurs in the method _getDaysInMonth in the file date_picker.dart:

return DateTimeRange(
  start: DateTime(year, month),
  end: DateTime(year, month + 1),
).duration.inDays;

Reproducing it for March 2024 it returns 30:

return DateTimeRange(
  start: DateTime(2024, 3),
  end: DateTime(2024, 3 + 1),
).duration.inDays;

But using DateTime.utc returns correctly 31:

return DateTimeRange(
  start: DateTime.utc(2024, 3),
  end: DateTime.utc(2024, 3 + 1),
).duration.inDays;