-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise.js
More file actions
32 lines (26 loc) · 885 Bytes
/
exercise.js
File metadata and controls
32 lines (26 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import dayjs from 'https://unpkg.com/dayjs@1.11.10/esm/index.js';
import isSatSun from './exercise2.js';
const today = dayjs();
const deliveryDate = today.add(7, 'days');
console.log(today.add(1, 'month').format('MMMM, D'));
console.log(today.subtract(1, 'month').format('MMMM, D'));
console.log(deliveryDate.format('MMMM, D'));
console.log(deliveryDate.format('dddd'));
/*function isWeekend(date) {
console.log(date.format('dddd'));
}*/
//console.log(isWeeKend(dayjs()));
console.log(isSatSun(dayjs()));
function caldulatedelivery(deliverydate, r) {
let remainingday = r;
deliverydate = deliverydate;
while(remainingday) {
deliverydate = deliverydate.add(r, 'days');
if(!isSatSun(deliverydate))
{
remainingday -= 1;
}
}
return deliverydate;
}
console.log(caldulatedelivery(today, 3).format('MMMM, dddd, D'));