-
Notifications
You must be signed in to change notification settings - Fork 0
Methods getIndexOf*PeriodOnWhichDateIsIncluded
lapaliv edited this page May 10, 2020
·
1 revision
Your friend works 3 days, then he rests 2 days, then he works 3 days and so on. He started working on May 12, 2012. You need to find out if he will work on January 1, 2020.
const formatter = new DateTimeFormatter(2020, 1, 1);
const startedAt = new DateTimeFormatter(2012, 5, 12);
const indexOfPeriod = formatter.getIndexOfDayPeriodOnWhichDateIsIncluded(startedAt, [3, 2]);
// or
const indexOfPeriod = formatter.getIndexOfDayPeriodOnWhichDateIsIncluded(startedAt, 3, 2);
If the indexOfPeriod
is 0
, then this means that January 1, 2020 will fall on the first period (3 days). If the indexOfPeriod
is equal to 1
- for the second period (2 days).
You can specify an unlimited number of periods