Page 1 of 1

calender.bas

Posted: Tue Jun 03, 2008 9:58 am
by tass
Hi all
i have downloaded the calender.bas from the WIKI and i think that there is a mistake in this function:

Code: Select all

Public Function MonthDays(PYear As Word,PMonth As Byte) As Byte
        Const MonthLookup(13) As Byte = (0,31,29,31,30,31,30,31,31,30,31,30,31)	

        MonthDays = MonthLookup(PMonth)
        If PMonth = 2 Then
            If CheckLeap(PYear) Then
                Inc (MonthDays)
            EndIf  		 						 
        End If    
    End Function
it should be changed to this:

Code: Select all

Public Function MonthDays(PYear As Word,PMonth As Byte) As Byte
        Const MonthLookup(13) As Byte = (0,31,28,31,30,31,30,31,31,30,31,30,31)	

        MonthDays = MonthLookup(PMonth)
        If PMonth = 2 Then
            If CheckLeap(PYear) Then
                Inc (MonthDays)
            EndIf  		 						 
        End If    
    End Function

Posted: Tue Jun 03, 2008 6:59 pm
by TimB
Well Spotted. Did it show up only when your in leap years?

It was based on some code for unix time give to me by some one else. It took me ages to find the error.

I forgot it was put into calander.bas