5.2 Rata Die Implementation Examples

  1. The following is an implementation as a subroutine in QBASIC. It is valid for all dates up to the limits of the QBASIC implementation for long integers (32 bit signed arithmetic).

    SUB rata (rd AS LONG, year AS LONG, month AS INTEGER, day AS INTEGER)
    'INPUT: year, month, day which represents a Gregorian Date
    'OUTPUT: Rata Die number
    y& = year 'Do not modify input parameter
    m% = month 'Do not modify input parameter
    IF m% < 3 THEN
          m% = m% + 12
          y& = y& - 1
    END IF
    rd = day + (153 * m% - 457) \ 5 + INT(365.25# * y&) - INT(y& *.01) + INT(y& *.0025) - 306
    END SUB


  2. The following is an implementation as a subroutine in QBASIC. It is only valid for non-negative Rata Die.

    SUB rata (rd AS LONG, year AS LONG, month AS INTEGER, day AS INTEGER)
    'INPUT: year, month, day which represents a Gregorian Date
    'OUTPUT: Rata Die number
    '***WARNING*** only valid for non-negative Rata Die,
    ' i.e., dates from January 1 of the year 1 or later
    y& = year 'Do not modify input parameter
    m% = month 'Do not modify input parameter
    IF m% < 3 THEN
          m% = m% + 12
          y& = y& - 1
    END IF
    rd = day + (153 * m% - 457) \ 5 + 365& * y& + y& \ 4 - y& \ 100 + y& \ 400 - 306
    END SUB


AESIR RESEARCH HOME PAGE

Last Modified: April 7, 2005