Sometimes, Whimsy is Enough
I’ve been a bit in the doldrums this week. It’s never fun when your health suddenly changes, especially when it decides to do it in a terrifying manner. But that’s for another day.
As part of all this kerfuffle, I’ve been sat at home most of the week “to rest”. Rest, for me, takes a few different forms; if I’m in the mood, I’ll maybe play a video game, or I’ll work on a hobby project, or I’ll tinker around on a coding project — which, to the outside observer doesn’t really look any different to “work”. Guess where my head landed this week?
But whatever keeps us occupied, eh?
I’ve spent the last several hours faffing around with Rust, and GitHub Actions (mostly on the Actions part, TBH) to create a command line utility with it’s own CI/CD pipeline for building and releases. And what does this utility do? Is it anything useful? Or groundbreaking? You read the title of this post, didn’t you?
No, it doesn’t do anything useful. What it does do, is take a date and time, and convert it to the date format used by the Imperium of Man in the game Warhammer 40,000[1]. Why? Because sometimes making something silly, just for the sake of it, is enough to make you feel a little bit better about everything.
grimdate # output: 0 064 025.M3//10:53 local
grimdate --no-spaces # output: 0064025.M3//10:54 local
grimdate --is-iss # output: 1 064 025.M3//10:54 local
grimdate --date "1999-10-05T15:30:00+03:00" # output: 0 759 999.M2//12:30 local
grimdate --no-time # output: 0 064 025.M3
# options can be combined, e.g.,
grimdate -iSTd "2023-10-05T15:30:00+03:00" # output: 1759023.M3
I went a bit further and wrapped a dumb ZSH function around it so it gets output to my terminal as a rainbow.
grim() {
local input="$(grimdate)"
local red=$'\e[31m'
local yellow=$'\e[33m'
local green=$'\e[32m'
local cyan=$'\e[36m'
local magenta=$'\e[35m'
local reset=$'\e[0m'
echo -n "\n+++ "
print -n "$input" | \
sed "s/\([0-9]\{1,3\}\)/${red}\1${reset}/1" | \
sed "s/\([0-9]\{3\}\)/${yellow}\1${reset}/1" | \
sed "s/\([0-9]\{3\}\.M[0-9]\)/${green}\1${reset}/1" | \
sed "s/\([0-9]\{2\}:[0-9]\{2\}\)/${cyan}\1${reset}/1" | \
sed "s/\(local\)/${magenta}\1${reset}/1"
echo " +++\n"
}
Maybe I’ll add this to my prompt somewhere, or maybe I’ll forget about it in a few days. But that’s besides the (lack of) point.
If you’d like to play with this silly little toy, you can find the code and releases over on GitHub[2].