Year-1900-was-a-Leap-Year

From: Wil Baden <wilbaden_at_netcom.com>
Date: Sun, 27 Jun 1999 10:11:35 -0700 (PDT)

Year 1900 was a Leap Year?
==========================

(Who cares?)

`1/01/1901 M/D/Y 1/01/1900 M/D/Y -` is 366.

`2/28/1900 M/D/Y` is 58.

`3/01/1900 M/D/Y` is 60.

A correct description of SwiftForth's Modified Julian Day is

    The Modified Julian Day in SwiftForth is the number of
    the days since the day before 1 January 1900. It is
    valid for 1 March 1900 and after.

The customary meaning of Modified Julian Day is the last five
digits of the Julian Day, where the Julian Day is the number
of days since 1 January 4713 BC.

For those who don't already have it, here are words for
Julian Day.

{ ==========================================================

(From RTFM.MIT.EDU "calendars" article.)

   a = (14-month)/12
   y = year+4800-a
   m = month + 12*a - 3

  For a date in the Gregorian calendar:
   JDN = day + (153*m+2)/5 + y*365 + y/4 - y/100 + y/400 - 32045

  For a date in the Julian calendar:
   JDN = day + (153*m+2)/5 + y*365 + y/4 - 32083

========================================================== }

\ Treating March as the beginning of the year, multiply
\ months by 30.6 rounded to nearest integer to get days
\ from the beginning of the year. For example, February 28
\ is day 11 306 * 4 + 10 / 28 + of the preceding year.

VARIABLE Julian-Calendar \ ON for Julian calendar.

: JD ( day month year -- <Julian Day> )
    4800 + >R ( day month)( R: year+4800)
    3 - DUP 0< IF 12 + R> 1- >R THEN
    306 * 4 + 10 / + ( days)
    R@ 1461 4 */ +
    Julian-Calendar @ IF
        32083 -
    ELSE
        R@ 100 / - R@ 400 / + 32045 -
    THEN
    R> DROP ;

{ ==========================================================

  For the Gregorian calendar:
     a = JDN + 32045
     b = (4*(a+36524))/146097 - 1
     c = a - (b*146097)/4

  For the Julian calendar:
     b = 0
     c = JDN + 32083

  Then, for both calendars:
     d = (4*(c+365))/1461 - 1
     e = c - (1461*d)/4
     m = (5*(e-1)+2)/153

     day = e - (153*m+2)/5
     month = m + 3 - 12*(m/10)
     year = b*100 + d - 4800 + m/10

========================================================== }

\ 1461 is the usual number of days in 4 years.
\ 36524 is the usual number of days in a century.
\ 146097 is the number of days in 400 years.

: JD>DMY ( <Julian Day> -- day month year )
    Julian-Calendar @ IF
        32083 +
        0 >R
    ELSE
        32045 + ( a)
        DUP 36524 + 4 146097 */ 1- >R ( R: b)
        R@ 146097 4 */ - ( c)
    THEN
    DUP 365 + 4 1461 */ 1- >R ( R: b d)
    R@ 1461 4 */ - ( e)
    DUP 1- 10 * 4 + 306 / >R ( R: b d m)
    R@ 306 * 4 + 10 / - ( day)
    R@ 3 + R@ 10 / 12 * - ( day month)
    R> 10 / R> + 4800 - R> 100 * + ( day month year) ;

: BC NEGATE 1+ ;

.
Received on Sun Jun 27 1999 - 10:11:35 PDT


Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 02-Sep-2010. Archive updated nightly.