In order to build a timeline that can display any point in time I'm first going to need a datatype that can represent any point in time. It needs to be able to cope with any event from the Big Bang to a potential Big Crunch - that's roughly 13.7 billion years either way. In this post I'm going to look at the two likely candidates for this temporal datatype: Date and Number.
Date()
The standard way of storing a point in time in Actionscript is to use a Date object. The purpose of this class is to simplify the process of working with the various cycles of the modern Gregorian calendar. What's interesting about Date however is that for all its many methods and properties, it's internal value is stored as a single number representing the total number of milliseconds that have elapsed since the 1st of January 1970. This somewhat arbitrary reference point or origin is known as the epoch. When a programmer calls a method of the Date class, this base number is converted back into a human friendly value before being returned.
The Date class does a great job when working with contemporary dates and times but I need to store values far beyond this period. A few simple tests show that the Date class fails with historical dates prior to the late 1500's. This is because the Date class is a representation of the Gregorian calendar and that system of quantifying time did not come into effect until 1582a.d.
I need a datatype that is calendar system agnostic. This will allow me to take a value and render it with reference to any calendar system, historical event or astronomical cycle.
Number()
The obvious choice then is Number. It is after all at the root of the Date object as well. If I use this datatype but maintain the same epoch as the Date class then I can very easily transition between both systems. I haven't done any speed tests on this but I strongly suspect doing calculations with Numbers will be faster than with Dates.
As an aside AS3 offers us a couple of alternatives to Number in the shape of int and uint. Whilst these are useful in other situations a quick capacity test reveals they aren't large enough to hold the values I need. Number however is quite comfortable with values as far back as the beginning of the universe itself.