Strictly adhering to Lachman's Maxim (Complexity is a diseconomy of scale),
this method is designed to run super-bly as a stand-alone routine when the
the most BASIC of computer is the only resource--meaning minimal operating
system functionality beyond superBASIC as a command-line interpreter, and
no integer, nor floating point, variables.
It succeeds where other Methods do not when computing the day of the week
on lowly 8-bit-bus systems: having no need of C compilers which run on
bloated development systems as for Michael Keith's and others'.
Given:
D$ as a Date stamp YEARMoDa in basic ISO format
T$ as an Offsets' table;
F$ as a Flag to choose between Julian (=0) & Gregorian (=1)
the superBASIC routine below is to compute:
s$ as the offset year
g$ as the Gregorian Offset to a Julian result
w$ as the mod 7 day-number compatible with ISO 8601:
Sun=0 Mon=1 Tue=2 Wed=3 Thu=4 Fri=5 Sat=6.
REM Step 0 - defines the Offsets' table & the offset year:
LET T$="400351362402" : s$=INT(D$/10000-.03)
REM Step 1 - calculates Gregorian Offset:
LET g$=(s$DIV 100)&"32"DIV 16 *F$
REM Step 2 - computes the day-number within the week:
LET w$=(s$DIV 4+ D$(1TO 4)+ T$(D$(5TO 6))+ D$(7TO 8)+ g$)MOD 7
This routine is valid for Gregorian dates as of 15.oct.1582, and for
historical Julian dates from 1.mar.1 until 4246 A.D.
--
REFERENCES
http://terdina.net/ql/ql.html
http://www.guernsey.net/~sgibbs/roman.html
gopher://gopherite.org/0/users/retroburrowers/TemporalRetrology/cc/os
Response:
text/plain