Dates and Times


What is the base day, year for LocalDate()? I need to convert from LocalDate()/LocalTime() to a unix time() value (seconds since 00:00:00 GMT, Jan. 1, 1970).


LocalTime is the number of milliseconds from midnight. LocalDate is... well, what can I say?

November 17, 1858 is day zero according to Magic Cap's date calculations. This method of calculating dates was NOT the caffeine induced delusion of a General Magic System Engineer (although the decision to use it may have been). It is known as the Modified Julian Date, and its history goes back hundreds of years. It is named after Julius Ceasar. "Of course, the Emperor" you say. Hah! Wrong on TWO counts! Not only was Julius Ceasar never emperor (Brutus and his buddies killed him before he got the chance), but it's a completely different Julius Ceasar (who never even came close to being emperor). I am referring to the sixteenth century Italian physician, Julius Ceasar Scaliger. "What did he do?" you ask. Well, faster than you can say "Forget I asked", I'll tell you. He had a son, named Joseph Julius Scaliger, a French scholar, who in 1583, developed a system for calculating days beginning with January 1, 4713 BC. Joe named it the Julian Day System, in honor of his father, and it would be cynical to believe that the fact that Joseph's middle name is Julius was anything other than purely coincidental.

Anyhow, this system of numbering days was soooooo nifty that the International Astronomical Union adopted it for their own devious purposes. Of course, now Julian dates get to be pretty big numbers, and so at some point (lost in the antiquity of time for the moment) the Modified Julian Date( MJD) was devised so we could use smaller numbers for calculations. The offset for MJD from a Julian Day Number (JDN) is 2,400,000 and a half. The reason the half is thrown in is because the Julian Day System starts at noon, and nowdays we start days at midnight (at least those of us in DTS).

I'm still not sure when the Modified Julian Date system was developed, or by whom. Presumably it was not Joseph, because he died in 1609 and therefore was not in a position to care much, one way or another, about the size of the calculations after November 17, 1858.

(The research for this answer was done by Gordon Sheridan. It's too bad his boss hates it so much.)


How do I get the local time zone? I need to do some time zone conversions.


Magic Cap uses Greenwich Mean Time as Universal Time. Time in other time zones are described as offsets in minutes from GMT. Objects of class City have a field, minutesFromGMT, which describes how far off Greenwich time that city is. For example, San Francisco's minutesFromGMT field contains the value -480, or eight hours later than GMT. The indexical iCurrentCity refers to the user's "home" city (the one that's got the arrow pointing to it on the world map). You can look at the minutesFromGMT field of the City object referred to by this indexical to calculate which time zone you're in.

Class DateTime contains a lot of time conversion utilities which you might find useful. Check out the chapter on Magic Cap Date and Time in Magic Cap Concepts to get an overview of these utilities.