isleapyear
function isleapyear( year ) --> res
Description
Checks if the given year is a leap year or not.
Parameters
- year
-
The year that needs to be checked as number.
Return Values
- res
-
true if the year is a leap year, otherwise false.
Code
--ZFUNC-isleapyear-v1 local function isleapyear( year ) --> res if( year % 4 == 0 and year % 100 ~= 0 ) or ( year % 400 == 0 ) then return true else return false end end return isleapyear
Examples
local t = require( "taptest" ) local isleapyear = require( "isleapyear" ) t( isleapyear( 1900 ), false ) t( isleapyear( 2001 ), false ) t( isleapyear( 2002 ), false ) t( isleapyear( 2000 ), true ) t( isleapyear( 2004 ), true ) t( isleapyear( 2008 ), true ) t()