EveryDueWorkdayMonth.from constructor
EveryDueWorkdayMonth.from(
- DateTime date, {
- WorkdayDirection direction = WorkdayDirection.forward,
Returns a EveryDueWorkdayMonth with the dueWorkday being the workday (monday, tuesday, wednesday, thursday or friday) of the given month.
When you call next or previous on, it will return the dueWorkday workday of the next or previous month.
If direction is WorkdayDirection.forward, it will return the next
workday if the given date is not a workday (monday).
If direction is WorkdayDirection.backward, it will return the previous
workday if the given date is not a workday (friday).
If direction is WorkdayDirection.none, it will throw an
ArgumentError if the given date is not a workday.
Implementation
factory EveryDueWorkdayMonth.from(
DateTime date, {
WorkdayDirection direction = WorkdayDirection.forward,
}) {
var local = date.copyWith();
if (!direction.isNone) {
local = WorkdayHelper.adjustToWorkday(date, isNext: direction.isForward);
}
return EveryDueWorkdayMonth(
WorkdayHelper.getWorkdayNumberInMonth(
local,
shouldThrow: direction.isNone,
),
);
}