Forgive me if I’m misunderstanding the problem, as I do not fully know what your intended application is, but it strikes me that the math is not so much the problem here as the structure. For dealing with very large spans of time (and distance in your case), where you need to be able to compare say what is happening on different planets at the same time. You will need a couple things to do this. First, you must understand you are creating a new calendar here, and that requires a few things of it’s own. Second you need to create a convenient way to display the time and perform math on it. I’m going to tackle these one at at time. Please bear with me me for the following as I’m about to completely geek out, I’ve spent way too much time thinking about time, and this looks fun to me.
First the calendar:
The first thing you need when creating a new calendar is a common point of reference. Every calendar must reference some past event as its start point; it’s epoch. For the modern Gregorian calendar used in the west, this is generally the birth of Christ, or the beginning of the “Common Era.” Since that is meaningless to someone living on another planet, you can throw that right out. The only reasonable reference point I see if we’re creating an intergalactic calendar would be the Big Bang. It’s the only universal reference point when you’re crossing galaxies. The Big Bang is estimated to have occurred about 13.7 billion years ago, so let’s start our new calendar there. In fact, let’s pretend it’s exactly 13.7 billion years, as of January 1 1900, just to make life easy. If you’re wondering why I chose that date, it’s just because that’s the date excel serializes dates from, so it’s one I’m used to working with. I didn’t say my reasons were great, I just said I had them.
Second, we need a standard unit of time with which to count and all it’s attendant subdivisions. Of course, in reality an earth day and year are totally meaningless to someone on another planet. However, since your game will be played by people on Earth (I presume), and it sounds like events in earth history will be frequently referenced, I think it would be forgivable to stick with a 24 hour day. However, since this is an intergalactic calendar, we have no cause to try to sync the calendar with the passing of seasons on any given planet so let’s not worry even trying to do so. For our purposes computational ease is far more important, especially considering you only need to be within a few centuries of a given date.
Given the above, our current arrangement of days and months with it’s odd and varying length of month etc does not lend itself to easy math. Or really even to easy numerical display. So we’ll just throw out the 12 month year entirely. Instead let’s use a 13 month year each month consisting of 28 days, and each day consisting of 24 hours. This gives us exactly 364 days per year, which does not line up with the earth year (365.242199 days per year). Were our calendar used on earth it would “wander” through the seasons. The months falling in spring this year, would eventually be in winter. However, this is the case with many real calendars here on earth (the islamic calendar and the Mayan calendar both suffer from the same defect) so I think it’s acceptable considering we’re not thinking only about earth here and those other calendars are!
No need to muck with anything lower than hours, it can all stay as it is in the regular time schema, nor anything larger than years. Centuries (100 years), millenia (1000 years), epoch (1 million years) and aeons (1 billion years) are all fine and quite easy to do math on .
Okay, so if that’s all established, now we need a convenient way to display our new calendar and do math on it. First displaying our new time system. What we’ve created above can be displayed in a type of dot notation, though of course not everything works on the same base here. Our format will be:
aeons.epoch.millenia.century.years.months.days
Therefore, if we wanted to display today’s date using our new calendar and display schema (September 9th, 2012) it would look like this:
13.700.0.1.12.13.27
Since our calendar starts at the big bang, that would be 13 billion, seven hundred million, one hundred, twelve years, thirteen months and 27 days. (remember, the big bang happened Exactly 13.7 billion years before January 1, 1900). We could call this the galactic date (catchy huh?).
Ok, now for the math. To find the length of time between any two dates, you just subtract each position of one date from each position of the other. So if we wanted to know how long between today and say, Febuary 3rd 1936, we would just convert that second date into Galactic Date Format (GDF) and subtract as follows:
2/3/36 in GDF: 13.700.0.0.36.2.6
Therefore:
13.700.0.1.12.13.27
=
0.0.0.0.76.11.21
So the difference (in Galactic Standard Time, GST) is 76 years, 11 months 21 days. If as is the case with the years place in our above problem, the simple math would produce a negative number, you just borrow from the next higher place, much as you do in regular subtraction.
As an interesting aside, our new calendar now works in a way very similar to how the Mayan Long Count works.
So how do we make this work programmatically? Write a GalacticTime class, give it a unique namespace so it’s easy to use, and build your necessary functions and constructors there. Off the cuff I would suspect you would need a compare function, an add, subtract, and display function. It would perhaps also be useful to write a constructor that takes a date in the normal gregorian format and converts it into Galactic Time. You’ll also write your logic here for doing the math of course. I would suggest just having 7 int variables with the appropriate names (epoc, millenium etc), and having the constructor test to make sure each variable is within the acceptable range. This then makes all the math very simple.
From that point on whenever you need to do something with Galactic time, you just instantiate a new GalacticTime object and do whatever you need to do. The plumbing is all nicely kept out of your way in the GalacticTime class.
Let me know if this helps you out. If you want more percision with earth dates, I can help you with that, but the system will be somewhat more complex. If you’re not comfortable writing your own classes and constructors (it’s not that hard really), let me know and I might be able to find the time to write the script for you, it won’t really be very complicated. I won’t charge much for it, maybe we could even do a trade of services of some sort.
Cheers!