Compare commits
No commits in common. "9e59e7a92396aa504b1245eaaab695e7c09b07de" and "e254463b0e002ed3d2acb17662c9943a6708880b" have entirely different histories.
9e59e7a923
...
e254463b0e
@ -46,15 +46,19 @@ 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,30 +449,6 @@ 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
|
||||||
@ -485,27 +461,23 @@ if [ "${1:-}" = "--preview-week" ]; then
|
|||||||
year_cur=$1
|
year_cur=$1
|
||||||
month_cur=$2
|
month_cur=$2
|
||||||
day_cur=$3
|
day_cur=$3
|
||||||
# Previous months
|
# Previous month
|
||||||
set -- $(month_previous "$month" "$year")
|
if [ "$month" -eq 1 ]; then
|
||||||
month_pre="$1"
|
month_pre=12
|
||||||
year_pre="$2"
|
year_pre=$((year - 1))
|
||||||
set -- $(month_previous "$month_pre" "$year_pre")
|
else
|
||||||
month_pre2="$1"
|
month_pre=$((month - 1))
|
||||||
year_pre2="$2"
|
year_pre=$year
|
||||||
# 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
|
fi
|
||||||
|
# Next month
|
||||||
|
if [ "$month" -eq 12 ]; then
|
||||||
|
month_nex=1
|
||||||
|
year_nex=$((year + 1))
|
||||||
|
else
|
||||||
|
month_nex=$((month + 1))
|
||||||
|
year_nex=$year
|
||||||
|
fi
|
||||||
|
# Highlight today
|
||||||
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
|
||||||
@ -515,20 +487,11 @@ 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
|
||||||
@ -589,10 +552,9 @@ 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} (now: $(date))"' \
|
--info-command='printf "Timezone: ${TZ:-as system} ($(date +"%Z"))"' \
|
||||||
--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