Re: Date arithmetic and Zune bug
- From: rpw3@xxxxxxxx (Rob Warnock)
- Date: Wed, 07 Jan 2009 06:10:03 -0600
H. Peter Anvin <hpa@xxxxxxxxx> wrote:
+---------------
| One important bit about anything dealing with Gregorian dates is the
| observation Christian Zeller did well over a century ago: the math gets
| a lot cleaner if you treat January and February as months 13 and 14 of
| (year-1). March was, in fact, historically the first month, as
| evidenced by our names for months 9 to 12: "September" ("seventh month")
| to "December" ("tenth month")...
+---------------
Eric Naggum's classic paper on the subject [known mostly among the Lisp
community, but applicable & readily accessible to a general audience]:
http://naggum.no/lugm-time.html
The Long, Painful History of Time
Erik Naggum, Naggum Software
Oslo, Norway
1999-10-11
suggests doing something very similar:
...
The Roman tradition of starting the year in the month of March
has also been lost. Most agrarian societies were far more
interested in the onset of spring than in the winter solstice,
even though various deities were naturally celebrated when the
sun returned. ...but Julius Caesar decided to move the Roman
calendar back two months... far more important was the decision
to retain the leap day in February. In the old calendar, the
leap day was added at the end of the year, as makes perfect
sense, when the month was already short, but now it is squeezed
into the middle of the first quarter, complicating all sorts of
calculations, and affecting how much people work. In the old
days, the leap day was used as an extra day for the various
fertility festivities.
[If one starts the year on March 1st] the simplicity of the scheme
is quite amazing: a 400-year cycle not only starts 2000-03-01
(as it did 1600-03-01), it contains an even number of weeks: 20,871.
This means that we can make do with a single 400-year calculation
for all time within the Gregorian calendar with respect to days of
week, leap days, etc.
...
The LOCAL-TIME Concept
...
Because we are [in 1999] very close to the beginning of the next
400-year leap-year cycle, thanks to Pope Gregory, day 0 is defined
to be 2000-03-01, which much less arbitrary than other systems,
but not obviously so. Each 400-year cycle contains 146,097 days,
so an arbitrary decision was made to limit the day to a maximal
negative value of -146,097, or 1600-03-01. This can be changed
at the peril of accurately representing days that do not belong
to the calendar used at the time.
...
[Because bignum arithmetic is expensive] The LOCAL-TIME concept
therefore represents time as three disjoint fixnums [relatively
small tagged integers that consume only one machine word, including
a few bits of type tag]:
1. the number of days since (or until, when negative) 2000-03-01
2. the number of seconds since the start of the day in
Coordinated Universal Time
3. the number of milliseconds since the start of the second.
All numbers have origin 0. Only the number of days may be negative.
...[more details about why this makes sense, how conversions and
date/time calculations (including intervals) are done in the system]...
Note: Even if you don't care for his proposed system, the paper is
a delightful tour of calendric history which touches on the influences
of geography, politics, science, and general historical randomness. ;-}
-Rob
-----
Rob Warnock <rpw3@xxxxxxxx>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
.
- Follow-Ups:
- Re: Date arithmetic and Zune bug
- From: kenney
- Re: Date arithmetic and Zune bug
- From: Muzaffer Kal
- Re: Date arithmetic and Zune bug
- From: nmm1
- Re: Date arithmetic and Zune bug
- References:
- Date arithmetic and Zune bug
- From: Terje Mathisen
- Re: Date arithmetic and Zune bug
- From: H. Peter Anvin
- Date arithmetic and Zune bug
- Prev by Date: Re: Date arithmetic and Zune bug
- Next by Date: Re: Question on scalability of multi-core Processors
- Previous by thread: Re: Date arithmetic and Zune bug
- Next by thread: Re: Date arithmetic and Zune bug
- Index(es):
Relevant Pages
|