Geek alert! This is a technical article about some of the issues I ran into whilst extending iPhemeris's Ephemeris to cover a 5000 year period from 2500 BC to 2500 AD.
Initially I'd thought it would be a simple matter to add a few thousand more years to the database. Devices have a lot more storage these days and network and download speeds are faster than when iPhemeris was first created. So why not, easy peasy right?! I did the work to read the JPL Ephemeris files and the USNO asteroid ephemeris over 8 years ago (both use the same format to store data) and could easily create what iPhemeris uses in any format. So creating a database that covered a longer period of time was really only a matter of a few days work and given the relative frequency of requests for more data, I thought why not just add it as an In-App purchase.
It took only a few hours work to create the new tables and pull in 4 more asteroids/planetoids from the USNO Ephemeris (the more frequently requested ones): Hygiea, Astraea, Eris and Sedna. Then set about updating the various places in the iOS and MacOS versions of the code that handle date ranges, which bodies are supported, etc... and then bam... I'm up to my ass in alligators!
The main problem encountered was that Apple has built into its Date Pickers , Calendars and Date Formatters a hard coded proleptic basis for Gregorian Calendar dates prior to Oct. 15th, 1582 when the Gregorian Calendar began. Apparently the ISO has mandated that computer systems model and use proleptic Gregorian dates prior to the start of the Gregorian calendar. This would be fine if Apple had provided a way to turn that off if you know what you are doing and want to. But they didn't. They like to cater to the 99% and we astrologers need a Julian Calendar sometimes, and are in the 1%... lol.
In brief, Pope Gregory added 10 days to the calendar to help correct for the fact that seasons were getting out of alignment with actuality due to the Precession of the Equinoxes. This meant that when the Gregorian Calendar officially went into effect they added 10 days, so what would have been Oct. 5th, 1582 in the old calendar, became the 15th of October and in a proleptic Gregorian Calendar, if you enter a number of seconds for the day prior to Oct. 15th, you will get back Oct. 14th. This is bad when you need to provide the option to use Old Style dates, which most astrological researchers do.
At first I thought, ok no problem... all dates and times are simply a number of seconds from a fixed reference point. I can add a correction to un-prolepticize the Apple dates and then I can use all their Date Pickers and Calendars and formatters... nope. It gets too complicated with leap years, etc.
The upshot of all this was that I had to embark on a 3 month project go through the entire code basis and rigidly ensure that everything underlying used Julian dates. All of my astronomical calculations already did as astronomy has used that as the basis for the last 100 years because it has a nice mathematical uniformity enabling you to calculate dates far into the past. Onto these you can overlay any calendar you like.
Next I had to write all my own Date Formatters and Date Pickers. This was a scary undertaking because there are a lot of cultural and localization issues that one encounters with the display of dates. Fortunately I was able leverage some of the localization tools existent in Objective C to help with that. I must have succeeded because with one or two minor exceptions (now corrected) nobody noticed 🙂
As a result iPhemeris now has some very nice Date Pickers and Date formatters that can be customized precisely to astrological needs. And the date pickers eliminate some of the very strange behaviors encountered in the MacOS version and which were troublesome to people who type slowly. These are those in the current versions of iPhemeris for Mac v3.1.2 and iOS v10.5.