Open rodrisy opened 10 months ago
Currently the indexDay is calculated by counting the amount of days have passed since the starting date stated, while skipping any weekends. implement a function to also skip any vacation days/off days stated in a database.
`int calculateCycleDay(DateTime currentDate, int cycleDays) { DateTime startDay = DateTime(currentDate.year, 1, 1); while (startDay.weekday != DateTime.monday) { startDay = startDay.add(Duration(days: 1)); }
int daysBetween = 0; while (startDay.isBefore(currentDate)) { if (startDay.weekday != DateTime.saturday && startDay.weekday != DateTime.sunday) { daysBetween++; } startDay = startDay.add(Duration(days: 1)); }
int cycleDay = daysBetween % cycleDays; if (cycleDay == 0) { return cycleDays; } else { return cycleDay; } }`
i think i worked it out, not tested yet. issue closed temporarily
Currently the indexDay is calculated by counting the amount of days have passed since the starting date stated, while skipping any weekends. implement a function to also skip any vacation days/off days stated in a database.
`int calculateCycleDay(DateTime currentDate, int cycleDays) { DateTime startDay = DateTime(currentDate.year, 1, 1); while (startDay.weekday != DateTime.monday) { startDay = startDay.add(Duration(days: 1)); }
int daysBetween = 0; while (startDay.isBefore(currentDate)) { if (startDay.weekday != DateTime.saturday && startDay.weekday != DateTime.sunday) { daysBetween++; } startDay = startDay.add(Duration(days: 1)); }
int cycleDay = daysBetween % cycleDays; if (cycleDay == 0) { return cycleDays; } else { return cycleDay; } }`