X-Git-Url: https://git.madduck.net/etc/mutt.git/blobdiff_plain/a83d50d5a64488deb3796bbd0ca0a03b0516cc77..7013dfe93a05082153f79eca6c9e5c05b54d9d50:/.config/mutt/get-timestamp diff --git a/.config/mutt/get-timestamp b/.config/mutt/get-timestamp new file mode 100755 index 0000000..f165be6 --- /dev/null +++ b/.config/mutt/get-timestamp @@ -0,0 +1,34 @@ +#!/bin/sh +# +# get-timestamp - helper script to obtain a timestamp from the user +# +# Copyright © 2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +set -eu + +if [ -z "${__RLWRAPPED:-}" ] && [ -x $(command -v rlwrap) ]; then + __RLWRAPPED=true exec rlwrap "$0" "$@" +fi + +printf 'When should I tickle you about this message? ' >/dev/tty +read timespec &2 + exit 1 + ;; + @[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]) + date="$timespec";; + [0-9][0-9][0-9][0-9][-.][0-9][0-9][-.][0-9][0-9]) + date="$timespec";; + *[0-9]y) date="now + ${timespec%y} years 00:00";; + *[0-9]m) date="now + ${timespec%m} months 00:00";; + *[0-9]w) date="now + ${timespec%w} weeks 00:00";; + *[0-9]d|*[0-9]) date="now + ${timespec%d} days 00:00";; + *[0-9]h) date="now + ${timespec%h} hours";; + *) date="$timespec";; +esac + +exec date +'%s (%c)' -d "$date"