SMOLNET PORTAL home about changes
 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 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, yet doing more in 
 under 12 lines.

Given:

T$    as an Offsets' table
D$    as a Date stamp CCYYMMDD in basic ISO format, and
   N$        as its Offset:
  300        Julian (historical)
  325        Old-Style
  301        Gregorian;

the superBASIC subroutine below is to compute:

 s$    as the offset date Stamp
 i%    as the increment to the month index for O.-S. Jan=1 & Feb=2
 g%    as the Gregorian adjustment
 v%    as the leap days' increment
 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.

AUTO start,gap

 REM Step 0 - initialise parameters & Offsets' table
 LET T$="477358369479584432110655432210665433210065"
 LET i%=0 : s$=INT((D$-N$)/100)
 SELect ON N$
        ON N$= 325 
           IF D$(5TO 8)< 0325 THEN 
              LET i%=1 : IF D$(5TO 8)> 0300 THEN s$=s$+ 100
           END IF
 END SELect

 REM Step 1 - process the offset date Stamp
 LET v%=s$(1TO 4)DIV 4 : g%=T$(s$(1TO 2))*(N$(2)+N$(3))

 REM Step 2 - compute the day-number within the week
 LET w%=(v%+ D$(1TO 4)+ T$(D$(5TO 6))+ i%+ D$(7TO 8)+ g%)MOD 7

^space

This routine is valid for 3 different calendars as follows
 (O.-S. dates must likewise use 3 for March, etc, but Jan. &
  Feb. may use either 1 & 2, or 13 & 14, respectively):

       Old Style: circa 1100 to 2.sep.1752
          Julian: 1.mar.1000 to 31.dec.4246
       Gregorian: 15.oct.1582 to 28.feb.4300 - i.e. to span
                  a full 28-century cycle of century Offsets.

--

      REFERENCES

http://terdina.net/ql/ql.html
http://www.guernsey.net/~sgibbs/roman.html
http://de.wikipedia.org/wiki/Wochentagsberechnung#Jahrhundertziffer
gopher://gopherite.org/0/users/retroburrowers/TemporalRetrology/cc/4g
Response: text/plain
Original URLgopher://sdf.org/0/users/retroburrowers/TemporalRetrology/QL/L4
Content-Typetext/plain; charset=utf-8