1## README23An [fzf]-like tool to interactively select a date in a provided format.4567### Motivation89A variety of command-line utilities ([at], [journalctl], [mpick], [khal], …) allow passing dates in different formats via command-line options.10Entering these dates in the required formats manually can be cumbersome and annoying.11Inspired by [fzf], this utility allows visually selecting a date interactively through a TUI, thereby easing specification of dates for other command-line utilities.1213### Status1415The currently implemented feature set works well, more advanced features (like [fzf-like previews][fzf preview]) may be added in a future version.1617### Installation1819If you have a Haskell development environment setup and a compatible GHC version installed, you can install this utility by cloning the repository and running:2021 $ cabal install2223Alternatively, if you don't have a Haskell development environment, you can also install this software using [Guix].24Guix will automatically install a supported GHC version for you and add the binary to your `$PATH`.25In order to install `datepicker` this way run the following command2627 $ guix time-machine -C channels.scm -- package -f package.scm2829### Tests3031A test suite is available, it performs several checks on the TUI using [tmux] and requires the `datepicker` binary in your `$PATH`.32Once these requirements are satisfied, it can be invoked using:3334 $ cabal test3536### Usage Examples3738By default, `datepicker` requires selection of both a date and a time and prints the selected date in the [RFC 1123] date format.39The behavior can be customized using several command-line flags, e.g. the `-f` option allows specification of a different date format.40This format must be specified using the format strings supported by the [formatTime] function from Haskell's `time` library.41A few example usages are provided below.4243**at** — Execute a job at a specified time which is selected based on the current year (`-y`):4445 $ echo "ls ~" | at -m -t "$(datepicker -y -f %0Y%m%d%H%M)"4647**journalctl** — Select log entries newer than a given date from a span of three months (`-3`):4849 $ journalctl --since="$(datepicker -3 -f '%Y-%m-%d %H:%M:%S')"5051**mpick** — Select emails newer than a given date in the current month, skipping time selection (`-d`):5253 $ mlist ~/mail/INBOX | mpick -t "date >= \"$(datepicker -d -f %Y-%m-%d)\""5455Refer to the `--help` output for an overview of all supported command-line options.5657### Key Bindings5859Two input views are provided: (1) A date selection view and (2) a time selection view.6061**Date Selection:**6263* `Esc` / `q`: Abort selection, exit with non-zero exit status64* `Enter`: Confirm selection of focused date65* `Up` and `Down`: Change focus to date in previous/next week66* `Left` and `Right`: Change focus to previous/next date6768**Time Selection:**6970* `Esc` / `q`: Abort selection, exit with non-zero exit status71* `Enter`: Confirm selection of specified time72 * Note: If the time is invalid, confirming the selection won't be possible73 * In a future version, this may cause an error to be emitted74* `[0-9]`: Input a new digit at the highlighted location75* `Backspace`: Move cursor to previous time digit76* `Left` and `Right`: Move cursor to previous/next digit7778### License7980This program is free software: you can redistribute it and/or modify it81under the terms of the GNU General Public License as published by the82Free Software Foundation, either version 3 of the License, or (at your83option) any later version.8485This program is distributed in the hope that it will be useful, but86WITHOUT ANY WARRANTY; without even the implied warranty of87MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General88Public License for more details.8990You should have received a copy of the GNU General Public License along91with this program. If not, see <https://www.gnu.org/licenses/>.9293[fzf]: https://github.com/junegunn/fzf94[cal]: https://manpages.debian.org/unstable/ncal/cal.1.en.html95[at]: https://manpages.debian.org/unstable/at/at.1.en.html96[journalctl]: https://manpages.debian.org/unstable/systemd/journalctl.1.en.html#FILTERING_OPTIONS97[mpick]: https://manpages.debian.org/unstable/mblaze/mpick.1.en.html#EXAMPLES98[khal]: https://manpages.debian.org/unstable/khal/khal.1.en.html99[Guix]: https://guix.gnu.org100[formatTime]: https://hackage.haskell.org/package/time/docs/Data-Time-Format.html#v:formatTime101[RFC 1123]: https://datatracker.ietf.org/doc/html/rfc1123102[tmux]: https://tmux.github.io103[fzf preview]: https://manpages.debian.org/unstable/fzf/fzf.1.en.html#PREVIEW_WINDOW