You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
963 B
30 lines
963 B
1 year ago
|
import interval from "./interval";
|
||
|
import {durationMinute, durationWeek} from "./duration";
|
||
|
|
||
|
function weekday(i) {
|
||
|
return interval(function(date) {
|
||
|
date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7);
|
||
|
date.setHours(0, 0, 0, 0);
|
||
|
}, function(date, step) {
|
||
|
date.setDate(date.getDate() + step * 7);
|
||
|
}, function(start, end) {
|
||
|
return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
export var sunday = weekday(0);
|
||
|
export var monday = weekday(1);
|
||
|
export var tuesday = weekday(2);
|
||
|
export var wednesday = weekday(3);
|
||
|
export var thursday = weekday(4);
|
||
|
export var friday = weekday(5);
|
||
|
export var saturday = weekday(6);
|
||
|
|
||
|
export var sundays = sunday.range;
|
||
|
export var mondays = monday.range;
|
||
|
export var tuesdays = tuesday.range;
|
||
|
export var wednesdays = wednesday.range;
|
||
|
export var thursdays = thursday.range;
|
||
|
export var fridays = friday.range;
|
||
|
export var saturdays = saturday.range;
|