'************************************************************************** ' ' Algorithmus: ' Carl Friedrich Gauss ' w := ((26m - 2) div 10 + t + j - 2c + (j div 4) + (c div 4)) mod 7 ' mit w = wochentag, t = tag, m = monat, j = jahr, c = jahrhundert ' ' Quelle: ' Dos Toolbox 4/93 S. 96 (Bernd Luevelsmeyer: Wochentag und Sonnenzeit) ' Assembler-Implementation von Sven B. Schreiber, 24.12.1993 ' PowerBASIC 3.0/3.2 Umsetzung von Thomas Gohel, 21.11.1994 ' "Div. by Zero" zwischen 2001-2005 beseitigt von Th. Gohel, 13.01.1997 ' '************************************************************************** PRINT "Dieses Jahr f„llt Weihnachten auf den "; GetDatum$("24.12.1997");"!" FUNCTION GetDatum$(Datum$) public 'Wichtig: Das Datum muss immer mit Nullen aufgefllt sein, 'also z.B: 01.01.1994 Tag% = VAL(MID$(Datum$,1,2)) Monat% = VAL(MID$(Datum$,4,2)) Jahr% = VAL(MID$(Datum$,7,4)) ! mov cx, Jahr% ! mov dh, Monat% ! mov dl, Tag% ! dec dh ! sub dh, 2 ;2 monate subtrahieren ! jnb GetTag ! add dh, 12 ;monat korrigieren ! sub cx, 1 ;jahr korrigieren GetTag: ! inc dh ! mov ax, cx ;jahrhundert abtrennen ! mov cl, 100 ! div cl ! mov cx, ax ! mov al, 26 ;(26m - 2) div 10 ! mul dh ! sub ax, 2 ! mov dh, 10 ! div dh ! mov ah, 0 ;8 -> 16 bit ! mov dh, ah ! add ax, dx ;+ t ! mov dl, ch ;+ j ! add ax, dx ! mov dl, cl ;- 2c ! sub ax, dx ! sub ax, dx ! add ax, 7 ;+7 (verhindert Ueberlauf ' bei folgendem div) ! shr ch, 1 ;j div 4 ! shr ch, 1 ! shr cl, 1 ;c div 4 ! shr cl, 1 ! add cl, ch ;+ (j div 4) + (c div 4) ! mov dl, cl ! add ax, dx ! mov cl, 7 ;mod 7 ! div cl ! mov al, ah ! mov WochenTag%, al SELECT CASE WochenTag% CASE 0: GetDatum$ = "Sonntag (Sunday)" CASE 1: GetDatum$ = "Montag (Monday)" CASE 2: GetDatum$ = "Dienstag (Tuesday)" CASE 3: GetDatum$ = "Mittwoch (Wednesday)" CASE 4: GetDatum$ = "Donnerstag (Thursday)" CASE 5: GetDatum$ = "Freitag (Friday)" CASE 6: GetDatum$ = "Sonnabend (Saturday)" END SELECT END FUNCTION