SMOLNET PORTAL home about changes
 Strictly adhering to Lachman's Maxim (Complexity is a diseconomy of scale),
 this method is designed to run superbly as a stand-alone function when the
 the most BASIC of computer is the only resource--meaning minimal operating
 system functionality beyond superBASIC as the command-line interpreter, no
 values needed from user tables or system calls, let alone floating point.
 
 Although using a processor more sophisticated than found on four-function
 calculators, this method is simple to execute using Hans' original Method.
 It succeeds where other Methods do not when computing the day of the week
 on lowly 8-bit-bus systems: having no need of extra instructions for data
 stored in tables, nor for redundant operations as in Zeller's, yet doing
 much more in half a dozen statements.

Given:

 S    as a date stamp "YEARMoDa" in basic ISO format
 F    as a Flag to choose between sets of calendars (as below);

the superBASIC FuNction Iso% is to compute:

 y%    as YEAR
 m%    as the month's number, Mo
 d%    as the day's number therein, Da
 i$    whereby i$(2 TO 3) is the MonthIndex
 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.

DEFine FN Iso%(S,F)
LOCal y%,m%,d%,i$,w% 

   REM Step 0 - to isolate components of the date stamp:
   LET y%=S(1TO 4) : m%=S(5TO 6) : d%=S(7TO 8)

   REM Step 1 - to initiate Lachman's Congruence:
   LET i$=m%*256+ 19300 : S=S(1TO 6)- 3

   REM Step 2 - to compute the day-number within the week:
   LET w%=(F*S(1TO 2)&"32"DIV 16+ S(1TO 4)DIV 4+ y%+ i$(2TO 3)+ d%)MOD 7

RETurn w%
END DEFine Iso%

 The result is returned as an integer: Iso%("13071013",0)
 returns the day-number within the week (5 for Friday).

 Function Iso% is streamlined such that parameters are to be passed to it
 in proper format. For example, one must pass a flag of 1 for Gregorian
 dates as of 15.oct.1582, as well as 0 for historical Julian dates as of
 1.mar.1000, whereby all years divisible by 4 are leap. It still applies 
 for 29.feb.1900--a valid date for Orthodox countries like Russia & Greece.
 The function thereby gives compleat valid historical continuity of
 date-stamp-conversion for somewhere on the planet for all dates from
 1.mar.1000 to 31.dec.9999. Otherwise, it still gives valid conversions
 for Julian dates on the Orthodox calendar until 31.dec.4246 A.D.

--

      REFERENCES

gopher://gopherite.org/0/users/retroburrowers/TemporalRetrology/cc/os
http://en.wikipedia.org/wiki/Zeller%27s_congruence
http://www.guernsey.net/~sgibbs/roman.html
http://terdina.net/ql/ql.html
Response: text/plain
Original URLgopher://sdf.org/0/users/retroburrowers/TemporalRetrology/QL/JG
Content-Typetext/plain; charset=utf-8