Skip to content

Commit face951

Browse files
committed
updated week number in build script to match FF
1 parent a9fac28 commit face951

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

setversion.sh

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,18 @@ get_version() {
66
local version=$(date -u -d "$date" +"%y.%m.")$week_number
77
echo "$version"
88
}
9-
109
get_week_number() {
11-
local date=$1
12-
local first_day_of_month=$(date -u -d "$(date -u -d "$date" +"%Y-%m-01T00:00:00%z")" +"%Y-%m-%dT%H:%M:%S%z") # First day of the month
13-
local days_until_first_monday=$(( ( $(date -u -d "$first_day_of_month" +"%u") + 7 - 1 ) % 7 )) # Days until the first Monday of the month
14-
local first_monday_of_month=$(date -u -d "$first_day_of_month +$days_until_first_monday days" +"%Y-%m-%dT%H:%M:%S%z") # First Monday of the month
10+
local date="$1"
11+
local first_day_of_month=$(date -d "$date" +%Y-%m-01)
12+
local first_day_of_week="Monday"
13+
14+
# Find the first day of the week that falls on or before the first day of the month
15+
while [[ $(date -d "$first_day_of_month" +%A) != "$first_day_of_week" ]]; do
16+
first_day_of_month=$(date -d "$first_day_of_month - 1 day" +%Y-%m-%d)
17+
done
1518

16-
if [[ $date < $first_monday_of_month ]]; then
17-
echo 1
18-
else
19-
local week_number=$(( ( $(date -u -d "$date" +"%d") - $(date -u -d "$first_monday_of_month" +"%d") ) / 7 + 1 ))
20-
local next_monday=$(date -u -d "$first_monday_of_month +$((week_number * 7)) days" +"%Y-%m-%dT%H:%M:%S%z")
21-
22-
if [[ $next_monday > $date ]]; then
23-
echo $week_number
24-
else
25-
echo $((week_number + 1))
26-
fi
27-
fi
19+
local week_number=$((($(date -d "$date" +%s) - $(date -d "$first_day_of_month" +%s)) / (60 * 60 * 24 * 7) + 1))
20+
echo "$week_number"
2821
}
2922

3023
versionNumber=$(get_version)

0 commit comments

Comments
 (0)