Skip to content

Commit 4976692

Browse files
author
Bohdan Potměkleč
committed
Fix week and previous-week aliases
On Mondays, they gave the week before the wanted week
1 parent 0408edb commit 4976692

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

stup

+4-4
Original file line numberDiff line numberDiff line change
@@ -1195,11 +1195,11 @@ extract_from_to_dates()
11951195
{
11961196
case "$FROM_TO_ALIAS" in
11971197
week)
1198-
FROM_AT=$(date -d "$(date -d yesterday +%u) days ago" +"%Y-%m-%d")
1198+
FROM_AT=$(date -d "$(($(date +%u) - 1)) days ago" +"%Y-%m-%d")
11991199
TO_AT=$(date -d "$FROM_AT + 6 days" +"%Y-%m-%d")
12001200
;;
12011201
previous-week)
1202-
local first_date_of_current_week=$(date -d "$(date -d yesterday +%u) days ago" +"%Y-%m-%d")
1202+
local first_date_of_current_week=$(date -d "$(($(date +%u) - 1)) days ago" +"%Y-%m-%d")
12031203
FROM_AT=$(date -d "$first_date_of_current_week -7 days" +"%Y-%m-%d")
12041204
TO_AT=$(date -d "$first_date_of_current_week -1 days" +"%Y-%m-%d")
12051205
;;
@@ -1212,8 +1212,8 @@ extract_from_to_dates()
12121212
TO_AT=$(date -d "$(date +'%Y-%m-01') - 1 second" +"%Y-%m-%d")
12131213
;;
12141214
year)
1215-
FROM_AT=$(date -d "today" +"%Y-01-01")
1216-
TO_AT=$(date -d "today" +"%Y-12-31")
1215+
FROM_AT=$(date +"%Y-01-01")
1216+
TO_AT=$(date +"%Y-12-31")
12171217
;;
12181218
previous-year)
12191219
FROM_AT=$(date -d "today - 1 year" +"%Y-01-01")

0 commit comments

Comments
 (0)