« Reading List: The Rise of the Meritocracy | Main | UNUM: Unicode/HTML/Numeric Character Code Converter Released »

Friday, January 27, 2006

Calendar Converter: Six-Hour Typo Fix, Calendar Queries

An eagle eyed visitor to the site spotted a single character typographical error in Calendar Converter that's been in there ever since it was first posted in 1999. It's fixed now—after six hours of flailing away; to the best of my recollection this is the most time I have ever spent fixing a single fat-finger in more than thirty-five years of programming. The error was in the Hebrew calendar section, where I misspelled the eighth month of the year, חשון (Heshvan), as השון. (If you don't see the Hebrew letters in the last sentence or they're in reverse order, I'm sorry—it's beyond my control; they're properly defined in the document, but your browser may lack Unicode support, not have access to a complete font, or fail to properly render bidirectional text.) To avoid just these kinds of problems, when I created Calendar Converter in 1999, I made the Hebrew month names images which were swapped by the JavaScript code which computes calendar dates. That will work on any browser with JavaScript support, which is a prerequisite for using the page in the first place.

Also, back in 1999, I didn't have a good looking Hebrew font on my Linux development machine, so I made the master images with Microsoft Word using the Hebrew Multimode font I developed for the first edition of the on-line Hebrew Bible. (Note: there is at least one error in this font which, since I no longer have the tools with which it was created, nor is the font used any more by the on-line Bible, will not be fixed. I do not recommend you use this font in any case, as modern documents should use Unicode rather than language-specific fonts.) Well, I figured, all I have to do is bring up the document, change the initial “he” to “het”, and that's that. Of course, any time you find yourself thinking “all I have to do” you should pull out the agenda and block out plenty of time for surprises and irritation. This was no exception: due to little changes over the years in each and every software tool in the chain between the source document and the final image, a total of six hours went down the rat hole before I had the new month name images in hand. Had I known it would take that long, naturally I'd have started over with a more modern process, but that isn't how it works—you're always sure the next little fix is all that's needed to get it to work and when it isn't, the good old “sunk investment” fallacy kicks in and keeps you plodding on toward the goal.

While I had Calendar Converter torn apart for maintenance, I decided to add something that's been on the list for quite a while: the ability to preset the date displayed in a variety of (but, as yet, not all) calendar systems. This is done by appending a “query string” preceded by a question mark to the URL used to invoke Calendar Converter. Query strings are most often used to supply arguments to CGI programs, but are equally accessible to JavaScript code embedded in pages. You can currently specify dates in either the Gregorian or Julian calendars; as a Julian day or Modified Julian day number and fraction; a Unix time() value; an ISO-8601 year and day or year, week, and day; or a Microsoft Excel day serial number in either the 1900 (PC) or 1904 (Macintosh) date system. The following list gives examples of the various query formats, all set to the date and time of the launch of Sputnik I, 19:28:34 UTC on October 4th, 1957. (The ISO date formats do not permit specification of a time, so the calendar page displayed when you click their links will show the time as midnight.) The delimiter between the date and time in Gregorian and Julian specifications may be any non-numeric character.

Gregorian
?Gregorian=1957-10-04T19:28:34
Julian Day
?JD=2436116.3115
Modified Julian Day
?MJD=36115.8115
Julian Calendar
?Julian=1957-9-21@19:28:34
Unix time()
?unixtime=-386310686
ISO-8601 Year, Week, and Day
?ISO=1957-W40-5
ISO-8601 Year and Day
?ISO=1957-277
Excel (1900/PC System)
?Excel=21097.8115
Excel (1904/Macintosh System)
?Excel1904=19635.8115
Using this feature, it's now possible to cite a date in a document which, when clicked, will launch Calendar Converter to display that date in all the available calendars. I'm planning to eventually extend this to allow an additional argument to specify that the result be returned as an XML document which can be easily parsed by the requester, allowing Calendar Converter to be invisibly embedded in Web applications.

Posted at January 27, 2006 00:13