Happy 2,460,496!

I was thinking about calendar conversions the other day and remembered that it had been years since I used my date-convert script. I wondered if it would still run. It didn’t, but it was easy to fix.

The first problem was the shebang line. date-convert is written in Emacs Lisp, and the first line used to be

#!/usr/bin/emacs --script

Because Apple no longer includes Emacs as part of macOS, there’s no executable with that name at that location anymore. The Emacs on my computer now was installed via Homebrew and is where all the other Homebrew executables are. So I changed the shebang line to

#!/opt/homebrew/bin/emacs --script

That made it run fine if called with no arguments, but it failed if run with arguments, i.e.,

$ date-convert 7 4 1776

Error: void-function (string-to-int)

[many lines of error messages]

Symbol’s function definition is void: string-to-int

I looked up the Emacs Lisp string conversion functions and found that string-to-int had been replaced with string-to-number.1 So I changed that function call and everything was hunky-dory.

For reasons lost in the mists of time, I originally had one of the conversions be to the Mayan calendar. Maybe that’s because there was a lot of silly talk back then about the Mayan calendar predicting the end of the world. Whatever the reason, I didn’t care about that conversion anymore, so I dropped it.

I then added the Julian Day Number, which seemed like it could conceivably be useful if I ever need to look up some astronomical observation from back when Western calendars were in flux. OK, that’s pretty unlikely, but it’s more likely than needing the Mayan calendar. I labeled the JDN “Astro” in the script’s output.

So the source code for date-convert is now this:

#!/opt/homebrew/bin/emacs --script

(require 'calendar)

; Use current date if no date is given on the command line
(if (= 3 (length command-line-args-left))
    (setq my-date (mapcar 'string-to-number command-line-args-left))
    (setq my-date (calendar-current-date)))

; Make the conversions and print the results
(princ
  (concat
    "Gregorian:  " (calendar-date-string          my-date)  "\n"
    "      ISO:  " (calendar-iso-date-string      my-date)  "\n"
    "    Astro:  " (calendar-astro-date-string    my-date)  "\n"
    "   Julian:  " (calendar-julian-date-string   my-date)  "\n"
    "   Hebrew:  " (calendar-hebrew-date-string   my-date)  "\n"
    "  Islamic:  " (calendar-islamic-date-string  my-date)  "\n"
    "  Chinese:  " (calendar-chinese-date-string  my-date)  "\n" ))

It works like this. With no arguments, it converts today:

$ date-convert
Gregorian:  Thursday, July 4, 2024
      ISO:  Day 4 of week 27 of 2024
    Astro:  2460496
   Julian:  June 21, 2024
   Hebrew:  Sivan 28, 5784
  Islamic:  Dhu al-Hijjah 27, 1445
  Chinese:  Cycle 78, year 41 (Jia-Chen), month 5 (Geng-Wu), day 29 (Ji-Si)

With three arguments (in the American ordering of month, day, year) it converts the given day:

$ date-convert 7 4 1776
Gregorian:  Thursday, July 4, 1776
      ISO:  Day 4 of week 27 of 1776
    Astro:  2369916
   Julian:  June 23, 1776
   Hebrew:  Tammuz 17, 5536
  Islamic:  Jumada I 17, 1190
  Chinese:  Cycle 74, year 33 (Bing-Shen), month 5 (Jia-Wu), day 19 (Ji-Chou)

So it’s been 90,580 days since the signing of the Declaration of Independence. If you’re wondering when we’ll hit the 100,000-day mark, that’ll be on JDN 2,469,916, or April 19, 2050. I’m hoping to still be around then, and I hope the country is, too.


  1. The documentation makes it sound as if both functions existed simultaneously and string-to-int was dropped as an unnecessary redundancy. I don’t feel like digging through change logs to get the full story.