<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/IsLeapYear?action=history&amp;feed=atom</id>
	<title>IsLeapYear - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/IsLeapYear?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsLeapYear&amp;action=history"/>
	<updated>2026-06-20T22:08:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=IsLeapYear&amp;diff=24064&amp;oldid=prev</id>
		<title>NeonBlack: new version of IsYearALeapYear and updated example</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsLeapYear&amp;diff=24064&amp;oldid=prev"/>
		<updated>2010-07-19T10:38:01Z</updated>

		<summary type="html">&lt;p&gt;new version of IsYearALeapYear and updated example&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function checks if a year is a leap year or not.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool isLeapYear( [ int year=getRealTime().year+1900 ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''year''': The year you want to check. Default is your local year.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the year is a leap year, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server- and/or clientside Script&amp;quot; class=&amp;quot;both&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function isLeapYear(year)&lt;br /&gt;
    if year then year = math.floor(year)&lt;br /&gt;
    else year = getRealTime().year + 1900 end&lt;br /&gt;
    return ((year % 4 == 0 and year % 100 ~= 0) or year % 400 == 0)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example tells the player if the given year is a leap year.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- define the command handler&lt;br /&gt;
addCommandHandler(&amp;quot;isYearALeapYear&amp;quot;, function (source, cmd, year)&lt;br /&gt;
    -- check if the player passed a year&lt;br /&gt;
    year = tonumber(year) or getRealTime().year + 1900&lt;br /&gt;
    -- check if the given year is a leap year&lt;br /&gt;
    local leapYear = IsYearALeapYear(year)&lt;br /&gt;
    --send an answer to the player&lt;br /&gt;
    if leapYear then&lt;br /&gt;
        outputChatBox(&amp;quot;The year &amp;quot;..year..&amp;quot; is a leap year.&amp;quot;, source)&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox(&amp;quot;The year &amp;quot;..year..&amp;quot; isn't a leap year.&amp;quot;, source)&lt;br /&gt;
    end&lt;br /&gt;
end, false, false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: NeonBlack&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>NeonBlack</name></author>
	</entry>
</feed>