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