mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-20 05:33:44 +02:00
fix: use DateTime(day + 1) rather than duration for adding and substracting days
This commit is contained in:
parent
fcbb71f88e
commit
dd4de52455
2 changed files with 12 additions and 8 deletions
|
@ -15,10 +15,16 @@ List<AvailabilityModel> getDefaultLocalAvailabilitiesForUser() {
|
|||
AvailabilityModel(
|
||||
id: availability.$1,
|
||||
userId: "",
|
||||
// TODO(Joey): Even though this is testdata, Never use .add(duration)
|
||||
// to move to the next day.
|
||||
startDate: currentMonth.add(Duration(days: availability.$2)),
|
||||
endDate: currentMonth.add(Duration(days: availability.$2)),
|
||||
startDate: DateTime(
|
||||
currentMonth.year,
|
||||
currentMonth.month,
|
||||
currentMonth.day + availability.$2,
|
||||
),
|
||||
endDate: DateTime(
|
||||
currentMonth.year,
|
||||
currentMonth.month,
|
||||
currentMonth.day + availability.$2,
|
||||
),
|
||||
breaks: [],
|
||||
templateId: availability.$3,
|
||||
),
|
||||
|
|
|
@ -250,11 +250,9 @@ List<CalendarDay> _generateCalendarDays(
|
|||
required bool isNextMonth,
|
||||
}) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
// TODO(Joey): Never increase days with duration, always use internal
|
||||
// datetime math.
|
||||
var day = isNextMonth
|
||||
? startDay.add(Duration(days: i + 1))
|
||||
: startDay.subtract(Duration(days: count - i));
|
||||
? DateTime(startDay.year, startDay.month, startDay.day + i + 1)
|
||||
: DateTime(startDay.year, startDay.month, startDay.day - count - 1);
|
||||
var isSelected = selectedRange != null &&
|
||||
!day.isBefore(selectedRange.start) &&
|
||||
!day.isAfter(selectedRange.end);
|
||||
|
|
Loading…
Reference in a new issue