CodeCogs - An iteractive open source Numerical library Welcome... Login
CodeCogs
shopping cart
OSXWindowsLinux
Search CodeCogs
Numerical Components

Valid RSS

UnitsDate

is Leap Year

Available under GPL (Free) and Commercial licence
get a GPL licence
COST (GBP)
this unit 1.17
sub units 0.00
add a commercial licence to your cart
0
viewed 3661 times and licensed 98 times

Returns true if the specified \a year is a leap-year in the Gregorian calendar (contains 29days in February). Open Office: ISLEAPYEAR

Controller: CodeCogs  Contact Controller
+View version details
Contents hide toc
buy now     get GPL     add to cart

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). Open Office: ISLEAPYEAR
ExcelBoolean cc_isLeapYear (Integer year)
This function is available as a Microsoft Excel add-in.

Function Documentation

Is Leap Year Calculator
  
Add calculator to website or email
 
boolisLeapYearintyear )[inline]
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:

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:

To view or download source code you need either a GPL or Commercial Licence.

buy now     get GPL     add to cart

Not a member, then Register with CodeCogs. Already a Member, then Login.


Page Comments

Format Excel Equations

  You must login to leave a messge


Last Modified: 18 Oct 07 @ 17:07     Page Rendered: 2010-03-14 20:52:39

Valid CSS!   Valid XHTML 1.0 Transitional