Absolute day numbers: Difference between revisions
m Protected "Absolute day numbers" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) |
No edit summary |
||
| Line 1: | Line 1: | ||
[[programming features|Programming Features]] - <strong>Absolute Day Numbers (ADN)</strong> | [[programming features|Programming Features]] - <strong>Absolute Day Numbers (ADN)</strong> | ||
== Absolute Day Numbers (ADN) == | |||
The | The BBS system stores the current date in the numeric variable <strong>DA</strong> using a format known as an <em>Absolute Day Number</em> (ADN). | ||
An ADN represents the total number of days that have elapsed since <strong>January 1, 1800 (01/01/1800)</strong>. 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 <strong>@15 through @19</strong> are used internally to perform ADN calculations and conversions. For detailed information about these functions, refer to the section <em>"ML Function Summary"</em>. | |||
=== Date Handling in the Time Routine === | |||
The <em>current time</em> routine located at line <strong>1110</strong> of each overlay also manages the system date. When midnight occurs, this routine increments the variable <strong>DA</strong> by one day. The updated value of DA is then used to calculate the other date-related variables. | |||
The following variables are derived from DA: | |||
{| class="wikitable" | |||
|- | |||
! Variable | |||
! Description | |||
|- | |||
| <strong>DA$</strong> | |||
| Current date in the format <code>MM/DD/YYYY</code> | |||
|- | |||
| <strong>D1</strong> | |||
| Current month (1–12) | |||
|- | |||
| <strong>D2</strong> | |||
| Day of week (0–6, where 0 = Sunday and 6 = Saturday) | |||
|- | |||
| <strong>D3</strong> | |||
| Day of the month (1–31) | |||
|- | |||
| <strong>D4</strong> | |||
| Current year (1800–9999) | |||
|} | |||
The formatted date string <strong>DA$</strong> is generated automatically from the ADN value. | |||
=== Month and Day Name Arrays === | |||
Two string arrays are provided for converting dates into readable text: | |||
{| class="wikitable" | |||
|- | |||
! Array | |||
! Contents | |||
|- | |||
| <strong>D1$()</strong> | |||
| Month names, where <code>D1$(1)</code> through <code>D1$(12)</code> correspond to January through December | |||
|- | |||
| <strong>D2$()</strong> | |||
| Day names, where <code>D2$(0)</code> through <code>D2$(6)</code> 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: | |||
{| class="wikitable" | |||
|- | |||
! Variable | |||
! Description | |||
|- | |||
| <strong>ED</strong> | |||
| Caller's membership expiration date | |||
|- | |||
| <strong>LD</strong> | |||
| Caller's last call date | |||
|- | |||
| <strong>BD</strong> | |||
| Caller's date of birth | |||
|} | |||
When user information is read from the password file, the corresponding formatted string variables are also generated automatically: | |||
* <strong>ED$</strong> – Membership expiration date (formatted) | |||
* <strong>LD$</strong> – Last call date (formatted) | |||
* <strong>BD$</strong> – 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: | |||
<code>difference = higher ADN − lower ADN</code> | |||
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: | |||
<code>future_date = DA + number_of_days</code> | |||
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 <strong>@27</strong> 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: | |||
<code>@27(DA,BD)</code> | |||
In this example: | |||
* <strong>DA</strong> – Current date | |||
* <strong>BD</strong> – Caller’s date of birth | |||
The function returns the number of full calendar years between the two dates. | |||
Next section: [[using disk drives|Using Disk Drives]] | Next section: [[using disk drives|Using Disk Drives]] | ||
[[programming features|Programming Features]] | [[programming features|Programming Features]] | ||
Revision as of 13:52, 7 March 2026
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.
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