aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRatakor <ratakor@disroot.org>2023-04-19 22:08:43 +0200
committerRatakor <ratakor@disroot.org>2023-04-19 22:08:43 +0200
commitebe54afd4f9c3e13492dc6ba0b812bb15dfcc001 (patch)
treebb52aa75daa5a68e121678e6d4189c78c41bb74f
parent167032155ffac03604c060ccf88dd356c88b2079 (diff)
add --date option
-rwxr-xr-xquand13
-rw-r--r--quand.12
2 files changed, 12 insertions, 3 deletions
diff --git a/quand b/quand
index 5102d54..3572c6a 100755
--- a/quand
+++ b/quand
@@ -18,13 +18,13 @@ spaces=" "
mondayfirst=0
getdate() {
- LC_ALL="$language" date --date="$1 day" "+%Y@%m@%d@%a$spaces"
+ LC_ALL="$language" date --date="$1 day" "+%Y/%m/%d/%a$spaces"
}
split() {
set -f
old_ifs=$IFS
- IFS=@
+ IFS=/
# shellcheck disable=SC2086
set -- $1
printf '%s\n' "$@"
@@ -81,6 +81,8 @@ args() {
past="$2" ;;
-f|--future)
future="$2" ;;
+ -d|--date)
+ date="$2" ;;
*)
printf '\033[31mError:\033[m unknown option %s\n' "$*" 1>&2
usage
@@ -88,6 +90,10 @@ args() {
esac
shift 2
done
+ if [ -n "$date" ]; then
+ future=0
+ past=0
+ fi
}
usage() {
@@ -100,6 +106,7 @@ e|edit | Edit the calendar file
c|cal [n] | Print a calendar with 1 or n months
|
-c|--calendar [path] | Temporarily change the calendar file used
+-d|--date [date] | Print events for a specific date, format: YYYY/MM/DD
-p|--past [n] | Temporarily change past (n is negative)
-f|--future [n] | Temporarily change future (n is positive)
-h|--help │ Print this help message
@@ -152,7 +159,7 @@ main() {
[ "$past" -eq -1 ] && print $(split "$(getdate "-1")") "$yesterday"
- print $(split "$(getdate 0)") "$today"
+ print $(split "${date:-$(getdate 0)}") "$today"
[ "$future" -ge 1 ] && print $(split "$(getdate "+1")") "$tomorrow"
diff --git a/quand.1 b/quand.1
index b5f580b..e7a4254 100644
--- a/quand.1
+++ b/quand.1
@@ -20,6 +20,8 @@ Print a calendar with 1 or
months.
.It Fl c , -calendar Ar path
Temporarily change the calendar file used.
+.It Fl d , -date Ar date
+Print events for a specific date with this format: YYYY/MM/DD.
.It Fl p , -past Ar n
Temporarily change past (n is negative).
.It Fl f , -future Ar n