File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < title > dayjs practice</ title >
5+ </ head >
6+ < body >
7+
8+
9+ < script type ="module " src ="8.js "> </ script >
10+ </ body >
11+ </ html >
12+
13+
14+
Original file line number Diff line number Diff line change 1+ import dayjs from 'https://cdn.jsdelivr.net/npm/dayjs/+esm' ;
2+ import isSatSun from './weekend.js' ;
3+
4+
5+ // 5 days after today, in the format of 'month' 'day of month'
6+ console . log ( dayjs ( ) . add ( 5 , 'days' ) . format ( 'MMMM dddd' ) )
7+
8+ // 1 month after today, in the format of 'month' 'day of month'
9+ console . log ( dayjs ( ) . add ( 1 , 'months' ) . format ( 'MMMM dddd' ) )
10+
11+ // 1 month before today, in the format of 'month' 'day of month'
12+ console . log ( dayjs ( ) . subtract ( 1 , 'months' ) . format ( 'MMMM dddd' ) )
13+
14+ // today, in the format of 'day of week'
15+ console . log ( dayjs ( ) . format ( 'dddd' ) )
16+
17+
18+
19+
20+ // will output true if day is either sunday or saturday, function is imported
21+ console . log ( isSatSun ( dayjs ( ) . format ( 'dddd' ) ) )
22+ console . log ( isSatSun ( dayjs ( ) . subtract ( 1 , 'days' ) . format ( 'dddd' ) ) )
23+ console . log ( isSatSun ( dayjs ( ) . subtract ( 3 , 'days' ) . format ( 'dddd' ) ) )
24+ console . log ( isSatSun ( dayjs ( ) . add ( 3 , 'days' ) . format ( 'dddd' ) ) )
Original file line number Diff line number Diff line change 1+ // check if today is weekend day
2+ function isWeekend ( date ) {
3+ if ( date === 'Sunday' || date === 'Saturday' ) {
4+ return true ;
5+ } else {
6+ return false ;
7+ }
8+ } ;
9+
10+ export default isWeekend ;
You can’t perform that action at this time.
0 commit comments