date_utils icon indicating copy to clipboard operation
date_utils copied to clipboard

Bug in daysInMonth - wrong startdate when date is a sunday

Open Paul-Todd opened this issue 7 years ago • 0 comments

I noticed that when the first weekday is a sunday an extra week is added in front.

The fix is to do a modulus on the daysBefore so if it is a sunday the remainder is zero and zero is subtracted.

date_utils:32 firstToDisplay = first.subtract(new Duration(days: daysBefore % 7));

With this fix the days now align with Microsoft Outlook monthly calendar as well as Google calendar monthly calendar

Paul-Todd avatar Oct 19 '18 19:10 Paul-Todd