An fzf-like tool to interactively select a date in a provided format
git clone https://git.8pit.net/datepicker.git
1## README 2 3An [fzf]-like tool to interactively select a date in a provided format. 4 5![Example usage with at(1) job scheduling](https://files.8pit.net/img/datepicker-demo-20250101.gif) 6 7### Motivation 8 9A 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### Status1415Basic functionally is operational and works.16However, I am not entirely happy with the keyboard navigation in the date selection view yet (see below).17Further, the command-line interface needs some refinement, specifically additional display options from [cal] (e.g. `-m`) would be nice to have (see `TODO.md`).1819### Installation2021If you have a Haskell development environment setup and a compatible GHC version installed, you can install this utility by cloning the repository and running:2223 $ cabal install2425Alternatively, if you don't have a Haskell development environment, you can also install this software using [Guix].26Guix will automatically install a supported GHC version for you and add the binary to your `$PATH`.27In order to install `datepicker` this way run the following command2829 $ guix time-machine -C channels.scm -- package -f manifest.scm3031### Usage Examples3233By default, `datepicker` requires selection of both a date and a time and prints the selected date in the [RFC 1123] date format.34The behavior can be customized using several command-line flags, e.g. the `-f` option allows specification of a different date format.35This format must be specified using the format strings supported by the [formatTime] function from Haskell's `time` library.36A few example usages are provided below.3738**at** — Execute a job at a specified time which is selected based on the current year (`-y`):3940 $ echo "ls ~" | at -m -t "$(datepicker -y -f %0Y%m%d%H%M)"4142**journalctl** — Select log entries newer than a given date from a span of three months (`-3`):4344 $ journalctl --since="$(datepicker -3 -f '%Y-%m-%d %H:%M:%S')"4546**mpick** — Select emails newer than a given date in the current month, skipping time selection (`-d`):4748 $ mlist ~/mail/INBOX | mpick -t "date >= \"$(datepicker -d -f %Y-%m-%d)\""4950Refer to the `--help` output for an overview of all supported command-line options.51The command-line interface is still subject to change, more options will likely be added in future versions.5253### Key Bindings5455Two input views are provided: (1) A date selection view and (2) a time selection view.5657**Date Selection:**5859* `Esc` / `q`: Abort selection, exit with non-zero exit status60* `Enter`: Confirm selection of focused date61* `Up` and `Down`: Change focus to date in previous/next week62* `Left` and `Right`: Change focus to previous/next date63 * Note: For the first/last day of the week the focus is changed to the previous/next month64 * This might change in a future version6566**Time Selection:**6768* `Esc` / `q`: Abort selection, exit with non-zero exit status69* `Enter`: Confirm selection of specified time70 * Note: If the time is invalid, confirming the selection won't be possible71 * In a future version, this may cause an error to be emitted72* `[0-9]`: Input a new digit at the highlighted location73* `Backspace`: Move cursor to previous time digit74* `Left` and `Right`: Move cursor to previous/next digit7576### License7778This program is free software: you can redistribute it and/or modify it79under the terms of the GNU General Public License as published by the80Free Software Foundation, either version 3 of the License, or (at your81option) any later version.8283This program is distributed in the hope that it will be useful, but84WITHOUT ANY WARRANTY; without even the implied warranty of85MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General86Public License for more details.8788You should have received a copy of the GNU General Public License along89with this program. If not, see <https://www.gnu.org/licenses/>.9091[fzf]: https://github.com/junegunn/fzf92[cal]: https://manpages.debian.org/unstable/ncal/cal.1.en.html93[at]: https://manpages.debian.org/unstable/at/at.1.en.html94[journalctl]: https://manpages.debian.org/unstable/systemd/journalctl.1.en.html#FILTERING_OPTIONS95[mpick]: https://manpages.debian.org/unstable/mblaze/mpick.1.en.html#EXAMPLES96[khal]: https://manpages.debian.org/unstable/khal/khal.1.en.html97[Guix]: https://guix.gnu.org98[formatTime]: https://hackage.haskell.org/package/time/docs/Data-Time-Format.html#v:formatTime99[RFC 1123]: https://datatracker.ietf.org/doc/html/rfc1123