Returns true if the specified \a year is a leap-year in the Gregorian calendar (contains 29days in February).
Open Office: ISLEAPYEAR
Controller:
Interface
#include <codecogs/units/date/isleapyear.h>
using namespace Units::Date;
bool | isLeapYear (int year)[inline]
Returns true if the specified year is a leap-year in the Gregorian calendar (contains 29days in February).
<span align="right" style="background-color:9999FF"><strong>Open Office: ISLEAPYEAR</strong></span> |
These functions are available for Microsoft Excel (
Login to download):
Boolean | cc_isLeapYear (Integer year) |
Use the following HTML code to embed the calculators within other websites:
IsLeapYear
Returns a boolean (true/false) to indicate if the specified
Year is a within a leap year.
In the Gregorian* calendar a typical year has 365 97/400 days = 365.2425 days. Therefore there are 97 leap years in every 400 years.
To facilitate this a leap year occurs when:
- the year is divisible by 4 but not divisible by 100, or
- the year is divisible by 400
So, 1700, 1800, 1900, 2100, 2200 are not leap years, but 1600, 2000, and 2400 are leap years.
(*) The Gregorian calendar was first introduced in 1582 by predominantly Catholic countries. This change occurred on the 4th October 1582, with 10 days being lost, such that 15th October was the next day. Today the vast majority of countries operate use the Gregorian calendar, the main exceptions being the Greek and Russian Orthodox churches, which still use the earlier Julian calendar.
Note this is not to be confused with the Julian date system standard that CodeCogs has adopted which defined any date as the number of days from 24 November 4714 BC in the Gregorian calendar (or the number of days from 1 January 4713BC in the Julian Calendar)
Example 1
- To output the number of days in each month of 1974
#include <stdio.h>
#include <codecogs/units/date/isleapyear.h>
int main()
{
for(int i=1900; i<2010; i++)
printf("\n%d %s a leap year", i, Units::Date::isLeapYear(i) ? "is":"is not");
return 0;
}
Note
- A leap year in the Julian calendar is simply any year divisible by 4, so we see no reasons to supply this as a distinct function. But here's the code (!!):
bool isJulianLeapYear= !(Year%4);
Authors
- Will Bateman (Sep 2004)
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.