forked from pixelb/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday
More file actions
executable file
·37 lines (30 loc) · 663 Bytes
/
day
File metadata and controls
executable file
·37 lines (30 loc) · 663 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
# Shows the date for "fri week" or "mon last" for e.g.
# License: LGPLv2
Usage () {
echo "Usage: `basename $0` mon|tue|... [next]|week|last" >&2
exit 1
}
[ "$#" -eq "0" ] && Usage
day=$1
which=$2
[ -z "$which" ] && which=next
case $which in
week)
if [ `date +%D` = `date --date="next $day" +%D` ]; then
weeks=+2 #assume we want the next week, not today
else
weeks=+1
fi ;;
last)
weeks=-1;;
next)
if [ `date +%D` = `date --date="next $day" +%D` ]; then
weeks=+1 #assume we want the next week, not today
else
weeks=+0
fi ;;
*)
Usage;;
esac
date --date="$day $weeks weeks" +%x