Guidance指路人g.yi.org software / rapidq / Examples / Date & Time / day of week.bas
 最新 LeonAutoBackup
```'From: jonaju0945  Sep 10th, 2002, 8:36pm

'Program Day-Of-Week or d-o-w
'this formula calculate the d-o-w for windos/unix programs

FUNCTION dow\$(d\$ AS STRING) AS STRING
DIM a AS INTEGER
DIM y AS INTEGER
DIM m AS INTEGER
DIM DOW AS INTEGER
DIM dd\$ AS STRING

dd\$="SunMonTueWedThuFriSat"
a = (14 - VAL(MID\$(d\$,1,2))) / 12 : y = VAL(MID\$(d\$,7,4)) - a
m = VAL(MID\$(d\$,1,2)) + 12 * (a - 2)
dow = (VAL(MID\$(d\$,4,2)) + y + y/4 - y/100 + y/400 + (31 * m)/12) MOD 7
dow\$=MID\$(dd\$,(dow*3)+1,3)
END FUNCTION

FUNCTION dow(d\$ AS STRING) AS INTEGER
DIM a AS INTEGER
DIM y AS INTEGER
DIM m AS INTEGER
DIM dd AS INTEGER

a = (14 - VAL(MID\$(d\$,1,2))) / 12 : y = VAL(MID\$(d\$,7,4)) - a
m = VAL(MID\$(d\$,1,2)) + 12 * (a - 2)
dow = (VAL(MID\$(d\$,4,2)) + y + y/4 - y/100 + y/400 + (31 * m)/12) MOD 7
END FUNCTION

D\$ = dow\$(DATE\$) 'return d-o-w in 3 letters format
D% = dow(DATE\$) 'return d-o-w in numbers 0=Sun
SHOWMESSAGE d\$+" - "+STR\$(d%)
```