A Return to the Shire

The Shire set in New Zealand, taken by Dodd Lu in 2017, showing the famous bridge and the mill

I wrote a Python program.

No vibe coding. No AI. Just me, an idea, the keyboard, a couple of hours of coding as time allowed, and finally about an hour’s worth of debugging.

In the autumn of 1999, I reread The Lord of the Rings and, for the first time, really studied the Appendices. Appendix D is on the calendars of Middle-earth, and it goes into some detail about the calendar in use in the Shire in the late Third Age.

I wrote a BASIC program that would convert a date into a Hobbit-style date. It wasn’t especially useful, but it was a nice little puzzle. A few years later I rewrote the program in PHP and built it into a WordPress plugin, and a few years after that, when I was writing VBA code at Diamond, I wrote a VBA version as well that would drop a Hobbit-style date into a Word document or Excel spreadsheet cell.

“Why don’t I rewrite this in Python?” I wondered. “It might make a nice, but silly, command line tool. Maybe even wrap it in a GTK framework.”

So that’s what I did.

The BASIC code was on the brutalist side. It did what it needed to do. It worked. But it was engineered for function, not form. It did what it did in an ugly way.

The Python code… Well, it’s better engineered. There’s still some brutalism to it — there are some things about the Shire calendar, like the days that exist outside of months, that require some direct handling — but it’s cleaner. Things I’d done manually in BASIC, like calculating the day of the year, Python has functions for. Python can do the work.

Once I’d debugged the thing, I had myself a command line utility that would tell me that today, July 27th, is the 7th day of Wedmath.

But that, I decided, was not enough.

Cowsay! A silly old Linux command line utility that prints in the terminal an ASCII cow with a speech bubble. And with a command line switch, I could also have other animals, Darth Vader, even Hello Kitty say things in the speech balloon.

Cowsay comes with a dragon. Actually, two dragon options.

And with some Unix piping, I could have a dragon give the date in a Hobbit-friendly form.

An ASCII dragon in the Linux terminal is telling me that the day is the 5th of Wedmath while breathing fire on an alarmed ASCII cow

So that’s what I’ve done.

I wrote a (silly) command line utility in Python.
I pipe the output into cowsay.
A dragon tells me the current date in the Shire.

I then set up a bash alias, so a single command in terminal does the trick:

alias shire="python3 ~/.local/bin/shire-reckoning | cowsay -f dragon-and-cow"

While I’d been thinking about a GTK framework to make a GUI desktop application, the cowsay dragon is the better outcome. Feels more authentic.

No one may care but me, but in my book “Mission Accomplished.” 🙂

Github repo here.

Post header photo, Hobbiton Movie Set, by Dodd Lu, licensed Creative Commons BY-NC-nd 2.0

Published by Allyn Gibson

A writer, editor, journalist, sometimes coder, occasional historian, and all-around scholar, Allyn Gibson is the writer for Diamond Comic Distributors' monthly PREVIEWS catalog, used by comic book shops and throughout the comics industry, and the editor for its monthly order forms. In his over fifteen years in the industry, Allyn has interviewed comics creators and pop culture celebrities, covered conventions, analyzed industry revenue trends, and written copy for comics, toys, and other pop culture merchandise. Allyn is also known for his short fiction (including the Star Trek story "Make-Believe,"the Doctor Who short story "The Spindle of Necessity," and the ReDeus story "The Ginger Kid"). Allyn has been blogging regularly with WordPress since 2004.

Leave a Reply

Your email address will not be published. Required fields are marked *