Welcome Guest, you are in: Login

Fruit Of The Shed

Navigation (MMBasic)






Search the wiki

»


IsLeapYear Function to determine if the given year is a Leap Year on the Gregorian (western) calendar

Modified on 2020/01/03 11:58 by CaptainBoing Categorized as Dates, Time and Clocks, Maths
The following is an MMBasic function to indicate that the given year is a leap year.

It simply returns a Boolean (actually an integer) of 1 if the year is leap or 0 if not.

Faster version eliminates decision making

Syntax:
=IsLeapYear(year)

Example Usage:
DaysInYear=365+IsLeapYear(year)
If IsLeapYear(year) Then...

	Function IsLeapYear(n As Integer) As Integer
		IsLeapYear=((n Mod 4=0) And (n Mod 100 <>0)) Or (n Mod 400=0) 		
	End Function

See Also:
IsDate and IsTime functions