Compare commits
4 Commits
e254463b0e
...
9e59e7a923
Author | SHA1 | Date | |
---|---|---|---|
9e59e7a923 | |||
afdf8430d0 | |||
b33acff21e | |||
f463b957bd |
@ -46,19 +46,15 @@ END {
|
||||
cmd | getline t
|
||||
close(cmd)
|
||||
t = t + 0
|
||||
print "fromnano="t
|
||||
if (t == 0) {
|
||||
print "ok, DATE-TIME type"
|
||||
from_type = "DATE-TIME"
|
||||
cmd = "date -d \"" from "\" +\"@%s\" | xargs date -u +\"%Y%m%dT%H%M00Z\" -d"
|
||||
} else {
|
||||
print "ok, DATE type"
|
||||
from_type = "DATE"
|
||||
cmd = "date -d \"" from "\" +\"%Y%m%d\"";
|
||||
}
|
||||
cmd | getline from
|
||||
close(cmd)
|
||||
print "FROM="from
|
||||
#
|
||||
to = to ? to : "now"
|
||||
cmd = "date -d \"" to "\" +\"%N\"";
|
||||
|
72
src/main.sh
72
src/main.sh
@ -449,6 +449,30 @@ if [ "${1:-}" = "--preview" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
month_previous() {
|
||||
month="$1"
|
||||
year="$2"
|
||||
if [ "$month" -eq 1 ]; then
|
||||
month=12
|
||||
year=$((year - 1))
|
||||
else
|
||||
month=$((month - 1))
|
||||
fi
|
||||
echo "$month $year"
|
||||
}
|
||||
|
||||
month_next() {
|
||||
month="$1"
|
||||
year="$2"
|
||||
if [ "$month" -eq 12 ]; then
|
||||
month=1
|
||||
year=$((year + 1))
|
||||
else
|
||||
month=$((month + 1))
|
||||
fi
|
||||
echo "$month $year"
|
||||
}
|
||||
|
||||
if [ "${1:-}" = "--preview-week" ]; then
|
||||
sign=$(echo "$2" | cut -d '|' -f 1)
|
||||
if [ "$sign" = "+" ]; then
|
||||
@ -461,23 +485,27 @@ if [ "${1:-}" = "--preview-week" ]; then
|
||||
year_cur=$1
|
||||
month_cur=$2
|
||||
day_cur=$3
|
||||
# Previous month
|
||||
if [ "$month" -eq 1 ]; then
|
||||
month_pre=12
|
||||
year_pre=$((year - 1))
|
||||
else
|
||||
month_pre=$((month - 1))
|
||||
year_pre=$year
|
||||
fi
|
||||
# Next month
|
||||
if [ "$month" -eq 12 ]; then
|
||||
month_nex=1
|
||||
year_nex=$((year + 1))
|
||||
else
|
||||
month_nex=$((month + 1))
|
||||
year_nex=$year
|
||||
fi
|
||||
# Previous months
|
||||
set -- $(month_previous "$month" "$year")
|
||||
month_pre="$1"
|
||||
year_pre="$2"
|
||||
set -- $(month_previous "$month_pre" "$year_pre")
|
||||
month_pre2="$1"
|
||||
year_pre2="$2"
|
||||
# Next months
|
||||
set -- $(month_next "$month" "$year")
|
||||
month_nex="$1"
|
||||
year_nex="$2"
|
||||
set -- $(month_next "$month_nex" "$year_nex")
|
||||
month_nex2="$1"
|
||||
year_nex2="$2"
|
||||
set -- $(month_next "$month_nex2" "$year_nex2")
|
||||
month_nex3="$1"
|
||||
year_nex3="$2"
|
||||
# Highlight today
|
||||
if [ "$month_pre2" -eq "$month_cur" ] && [ "$year_pre2" -eq "$year_cur" ]; then
|
||||
var_pre2=$day_cur
|
||||
fi
|
||||
if [ "$month_pre" -eq "$month_cur" ] && [ "$year_pre" -eq "$year_cur" ]; then
|
||||
var_pre=$day_cur
|
||||
fi
|
||||
@ -487,11 +515,20 @@ if [ "${1:-}" = "--preview-week" ]; then
|
||||
if [ "$month_nex" -eq "$month_cur" ] && [ "$year_nex" -eq "$year_cur" ]; then
|
||||
var_nex=$day_cur
|
||||
fi
|
||||
if [ "$month_nex2" -eq "$month_cur" ] && [ "$year_nex2" -eq "$year_cur" ]; then
|
||||
var_nex2=$day_cur
|
||||
fi
|
||||
if [ "$month_nex3" -eq "$month_cur" ] && [ "$year_nex3" -eq "$year_cur" ]; then
|
||||
var_nex3=$day_cur
|
||||
fi
|
||||
# show
|
||||
(
|
||||
cal "$month_pre2" "$year_pre2" | awk -v cur="${var_pre2:-}" "$AWK_CAL"
|
||||
cal "$month_pre" "$year_pre" | awk -v cur="${var_pre:-}" "$AWK_CAL"
|
||||
cal "$month" "$year" | awk -v cur="${var:-}" -v day="$day" "$AWK_CAL"
|
||||
cal "$month_nex" "$year_nex" | awk -v cur="${var_nex:-}" "$AWK_CAL"
|
||||
cal "$month_nex2" "$year_nex2" | awk -v cur="${var_nex2:-}" "$AWK_CAL"
|
||||
cal "$month_nex3" "$year_nex3" | awk -v cur="${var_nex3:-}" "$AWK_CAL"
|
||||
) | awk '{ l[NR%8] = l[NR%8] " " $0 } END {for (i in l) if (i>0) print l[i] }'
|
||||
fi
|
||||
exit
|
||||
@ -552,9 +589,10 @@ selection=$(
|
||||
--with-nth='{4}' \
|
||||
--accept-nth=1,2 \
|
||||
--ansi \
|
||||
--gap 1 \
|
||||
--no-scrollbar \
|
||||
--info=right \
|
||||
--info-command='printf "Timezone: ${TZ:-as system} ($(date +"%Z"))"' \
|
||||
--info-command='printf "Timezone: ${TZ:-as system} (now: $(date))"' \
|
||||
--preview-window=up,7,border-bottom \
|
||||
--preview="$0 --preview-week {}" \
|
||||
--expect="ctrl-n" \
|
||||
|
Loading…
Reference in New Issue
Block a user