Absolute day numbers

Revision as of 14:06, 7 March 2026 by Admin (talk | contribs)

Programming Features - Absolute Day Numbers (ADN)

Absolute Day Numbers (ADN)

The BBS system stores the current date in the numeric variable DA using a format known as an Absolute Day Number (ADN).

An ADN represents the total number of days that have elapsed since January 1, 1800 (01/01/1800). While this representation may seem unusual at first, it greatly simplifies date calculations. The Color 64 machine language routines perform all required conversions automatically, so most programs never need to manipulate the ADN value directly.

Under normal BBS operation, users never see ADN values. However, sysops who write programs or modules should understand how this system works.

Machine language functions @15 through @19 are used internally to perform ADN calculations and conversions. For detailed information about these functions, refer to the section "ML Function Summary".


Date Handling in the Time Routine

The current time routine located at line 1110 of each overlay also manages the system date. When midnight occurs, this routine increments the variable DA by one day. The updated value of DA is then used to calculate the other date-related variables.

Anytime you want to use one of the information variables listed below, you must perform the GOSUB to 1110.

The following variables are derived from DA:

Variable Description
DA$ Current date in the format MM/DD/YYYY
D1 Current month (1–12)
D2 Day of week (0–6, where 0 = Sunday and 6 = Saturday)
D3 Day of the month (1–31)
D4 Current year (1800–9999)

The formatted date string DA$ is generated automatically from the ADN value.


Month and Day Name Arrays

Two string arrays are provided for converting dates into readable text:

Array Contents
D1$() Month names, where D1$(1) through D1$(12) correspond to January through December
D2$() Day names, where D2$(0) through D2$(6) correspond to Sunday through Saturday

These arrays allow programs to display dates in plain English format.


Other ADN-Based Variables

Several additional variables store dates internally using ADN format:

Variable Description
ED Caller's membership expiration date
LD Caller's last call date
BD Caller's date of birth

When user information is read from the password file, the corresponding formatted string variables are also generated automatically:

  • ED$ – Membership expiration date (formatted)
  • LD$ – Last call date (formatted)
  • BD$ – Date of birth (formatted)


Calculating Differences Between Dates

Because dates are stored as Absolute Day Numbers, calculating the number of days between two dates is simple.

To determine the number of days between two dates:

difference = higher ADN − lower ADN

The result is the exact number of days between the two dates.


Calculating Future Dates

To determine the date after a specific number of days, simply add the desired number of days to the current ADN value:

future_date = DA + number_of_days

The resulting ADN can then be converted back into formatted date variables using the standard system routines.


Calculating Age or Year Differences

Machine language function @27 calculates the number of calendar years between two ADN values.

This function is commonly used to determine a caller's age from their stored date of birth:

@27(DA,BD)

In this example:

  • DA – Current date
  • BD – Caller’s date of birth

The function returns the number of full calendar years between the two dates.

Next section: Using Disk Drives

Programming Features