'Author : Daniel, Master Sourcerer at Kitana's Castle 'Last change: March 3, 2004 'Email : sourcerer@kitana.org #DIM ALL 'Returns the number of days a month has in a specific year 'Input : M& = month (1-12) ' Y& = year 'Output: number of days in this month FUNCTION MONTHDAYS&(M&,Y&) LOCAL D&,Z$ Z$=CHR$(31,28,31,30,31,30,31,31,30,31,30,31) D&=ASC(Z$,M&) 'assume default number of days IF M&=2 THEN 'special handling for February '29 days if year/4 unless year/100 except year/400 IF (Y& AND 3)=0 THEN IF (Y& MOD 400)=0 OR (Y& MOD 100)<>0 THEN D&=29 END IF END IF MONTHDAYS&=D& END FUNCTION 'Calculates how many days have passed from 1 AD to this date 'Input : D& = day (1-31) ' M& = month (1-12) ' Y& = year 'Output: number of days since 1 AD FUNCTION ABSOLUTEDAY&(D&,M&,Y&) LOCAL N&,I& 'Calculate years and days N&=Y&*365+INT(Y&/4)-INT(Y&/100)+INT(Y&/400)+D& 'Add months of this year FOR I&=1 TO M&-1 N&=N&+MONTHDAYS&(I&,Y&) NEXT I& ABSOLUTEDAY&=N& END FUNCTION 'Main program FUNCTION PBMAIN& PRINT ABSOLUTEDAY&(1,3,2004) WAITKEY$ END FUNCTION