added --new functionality with keybnding

This commit is contained in:
2025-06-10 14:29:55 +02:00
parent c7f5082671
commit 8824959715
2 changed files with 54 additions and 24 deletions

View File

@@ -33,36 +33,35 @@ BEGIN {
ENDFILE {
if (NR == FNR)
{
# Sanitize input
cmd = "date +\"%R\""
cmd | getline now
close(cmd)
# if time is set to 00:00 or right now, assume it's a date
# and not a datetime entry.
# If nanoseconds are not 0, then we assume user enterd "tomorrow" or
# something the like, and we make this a date entry, as opposed to a
# date-time entry.
from = from ? from : "now"
cmd = "date -d \"" from "\" +\"%R\"";
cmd = "date -d \"" from "\" +\"%N\"";
cmd | getline t
close(cmd)
if (t == "00:00" || t == now) {
from_type = "DATE"
cmd = "date -d \"" from "\" +\"%Y%m%d\"";
} else {
t = t + 0
if (t == 0) {
from_type = "DATE-TIME"
cmd = "date -d \"" from "\" +\"@%s\" | xargs date -u +\"%Y%m%dT%H%M00Z\" -d"
} else {
from_type = "DATE"
cmd = "date -d \"" from "\" +\"%Y%m%d\"";
}
cmd | getline from
close(cmd)
#
to = to ? to : "now"
cmd = "date -d \"" to "\" +\"%R\"";
cmd = "date -d \"" to "\" +\"%N\"";
cmd | getline t
close(cmd)
if (t == "00:00" || t == now) {
to_type = "DATE"
cmd = "date -d \"" to "\" +\"%Y%m%d\"";
} else {
t = t + 0
if (t == 0) {
to_type = "DATE-TIME"
cmd = "date -d \"" to "\" +\"@%s\" | xargs date -u +\"%Y%m%dT%H%M00Z\" -d"
} else {
to_type = "DATE"
cmd = "date -d \"" to "\" +\"%Y%m%d\"";
}
cmd | getline to
close(cmd)