|
36 | 36 | function next_release_date() { |
37 | 37 | target_day=$1 |
38 | 38 |
|
39 | | - # Get the current day of the week (0-6) |
40 | | - current_day=$($DATE_PATH +%u) |
41 | | - |
42 | | - # Calculate days until next target day |
43 | | - if [ "$current_day" -ge "$target_day" ]; then |
44 | | - days_until_target_day=$(( 7 + ($target_day + 7 - $current_day) % 7 )) |
| 39 | + # Calculate days until the next valid release day |
| 40 | + if [ "$current_day" -eq 3 ]; then |
| 41 | + # If today is Wednesday (3), skip Friday and schedule for Monday (5 days later) |
| 42 | + days_until_target_day=$(( 5 )) |
| 43 | + elif [ "$current_day" -eq 4 ]; then |
| 44 | + # If today is Thursday (4), schedule for Monday (4 days later) |
| 45 | + days_until_target_day=$(( 4 )) |
| 46 | + elif [ "$current_day" -eq 5 ]; then |
| 47 | + # If today is Friday (5), schedule for Tuesday (4 days later) |
| 48 | + days_until_target_day=$(( 4 )) |
| 49 | + elif [ "$current_day" -eq 6 ]; then |
| 50 | + # If today is Saturday (6), schedule for Tuesday (3 days later) |
| 51 | + days_until_target_day=$(( 3 )) |
| 52 | + elif [ "$current_day" -eq 0 ]; then |
| 53 | + # If today is Sunday (0), schedule for Tuesday (2 days later) |
| 54 | + days_until_target_day=$(( 2 )) |
45 | 55 | else |
46 | | - days_until_target_day=$(( ($target_day - $current_day) % 7 )) |
| 56 | + # For Monday (1), Tuesday (2), schedule two days ahead |
| 57 | + days_until_target_day=$(( 2 )) |
47 | 58 | fi |
48 | 59 |
|
49 | 60 | # Get the date of next target day in YYYY-MM-DD format |
|
0 commit comments