Russell [EMAIL PROTECTED]
See comments below:
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 02, 1999 2:07 PM
Subject: [REBOL] epoch? Re:(8)


> [snip - some algorithms]
>
> [EMAIL PROTECTED] wrote:
> >That appears to be a Julian day referenced to the start of the year.  My
> >understanding of a Julian day number is that it is the number of days
since
> >the start of the current Julian period, which started noon Jan 1 4713 BC.
>
> That's what a Julian date is in the real world :)
> As a computer term, a Julian date is any date calculated in the same
> manner as a real world Julian date, but possibly from a different base
> date. Whatever the base date is, that's called the epoch. The epoch
> for Unix is 1-Jan-1970, for DOS it's 1-Jan-1980.


For EXCEL, the MIS spreadsheet, it's jan 1 1900, which is day 1.  Negative
numbers are not convertible to dates.

> There are problems
> similar to Y2K when Julian date counters overflow or roll over.

That won't be for awhile!  32 bits can count days for over 11 million
years - not to worry!

>
> >Noon of Dec 31 1998 was the beginning of JD  2,451,179.  There is an
> >algorithm for calculating this number from a given date in the Gregorian
> >Calendar, our present calendar, but I don't have it at hand.  It requires
> >the use of a floor or ceiling function, the nearest integer smaller (or
> >greater) than a given decimal number.  The formula accounts for leap
years
> >and the days in each month.  It also starts a year on March 1, so
February
> >is the last month, and the formula truncates its length correctly.  I
> >implemented the formula in Forth using integers, but it was long ago -- .
>
> I don't know about anyone else here, but I'd be interested in seeing
> that algorithm if you could dig it up, even in Forth :)

I haven't found it yet, but I was doing some experiments in REBOL 2.2 and
it's pretty sophisticated! It knows that 1600 *was* a leap year, as it's a
multiple of 400, even though it's a multiple of 100, which are generally not
leap years  Also.

>> 1-1-1999 - 1-1-0000 / 365.2422
== 1999.00230586718
>>
Not too shabby an approximation of 1999 and possibly the error
>
But it doesn't like negative years:

>> 31-12-1998 - 1-1--0001 / 365.2422
== -63536.0536104535
>>
>> source to-date
to-date: func ["Converts to date value." value "Value to convert"][to date!
value]
>> source to
to: native [
    {Constructs and returns a new value after conversion.}
    type [any-type!] "The datatype or example value."
    spec [any-type!] "The attributes of the new value."
]
>> to-date [1 1 0000]
== 1-Jan-0000
>> to-date [1 1 -4317]
== 1-Jan-61219
>> to-date [1 1 -0001]
== 1-Jan-65535
Hmmm we're getting somewhere.  Looks like REBOL's epoch date is jan 1 0000,
and it uses 16 bits for years!

On the algorithms, I'll have to get back to it later.  Gotta go do an
errand!

> Brian
>

Reply via email to