One-liner script that extracts a date from e.g. the clipboard
Got annoyed by copy and pasting dates and times from web articles, then having to clean the copied stuff up (some websites make it hard to select the date without activating a link, so you end up with the author name or whatever, too).
Here's a simple one-liner to clean things up, requiring any Ruby installed:
ruby -e 'require "date"; print Date.parse(ARGF.read).iso8601
It's simpler than my previous attempts with a Python script that parses date and time, e.g. from a Zettel ID.
This reads from standard input, looks for a date inside, then prints the 2021-08-11 form of the date.
Here's how you can test it by piping static text to the command:
echo "Nassim Taleb Jun 14, 2020 · 5 min read" | ruby -e 'require "date"; print Date.parse(ARGF.read).iso8601'
You can use Keyboard Maestro, too, for this:
Author at Zettelkasten.de • https://christiantietze.de/
It looks like you're new here. If you want to get involved, click one of these buttons!