calender.bas

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
tass
Posts: 19
Joined: Sat Jan 19, 2008 8:37 am
Location: France

calender.bas

Post by tass » Tue Jun 03, 2008 9:58 am

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

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Tue Jun 03, 2008 6:59 pm

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

Post Reply