File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
basic-projects/amazon-project/data Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change 11import dayjs from 'https://cdn.jsdelivr.net/npm/dayjs/+esm' ;
22
3+
4+ function correctDate ( day ) {
5+
6+ const dayName = day . format ( 'dddd' )
7+
8+ if ( dayName === 'Sunday' ) {
9+ day = day . add ( 1 , 'days' )
10+ }
11+
12+ if ( dayName === 'Saturday' ) {
13+ day = day . add ( 2 , 'days' )
14+ }
15+
16+ // Format only once at the end.
17+ // Calling .format() earlier would convert `day` to a string
18+ // and break future Dayjs operations like .add()
19+ return day . format ( 'dddd, MMMM D' )
20+ }
21+
322export const deliveryOptions = [ {
423 id : '1' ,
5- date : dayjs ( ) . add ( 7 , 'days' ) . format ( 'dddd, MMMM D' ) ,
24+ date : correctDate ( dayjs ( ) . add ( 7 , 'days' ) ) ,
625 priceCents : 0
726} ,
827{
928 id : '2' ,
10- date : dayjs ( ) . add ( 3 , 'days' ) . format ( 'dddd, MMMM D' ) ,
29+ date : correctDate ( dayjs ( ) . add ( 3 , 'days' ) ) ,
1130 priceCents : 499
1231} ,
1332{
1433 id : '3' ,
15- date : dayjs ( ) . add ( 1 , 'days' ) . format ( 'dddd, MMMM D' ) ,
34+ date : correctDate ( dayjs ( ) . add ( 1 , 'days' ) ) ,
1635 priceCents : 999
1736} ] ;
1837
You can’t perform that action at this time.
0 commit comments