Contributed by Adam
on Sep 15, 2000 at 02:48 UTC
Q&A
> dates and times
Answer: Leap Year contributed by Adam The leap year formula is: A leap year is divisable by 4, but not by 100 (except if divisable by 400.)
if( 0 == $year % 4 and 0 != $year % 100 or 0 == $year % 400 )
{
# Then $year is a leap year.
}
| Answer: Leap Year contributed by Agyeya The Date::Leapyear module will tell if a year is a (Gregorian) leap year:
use Date::Leapyear;
if ( isleap(yyyy) ) {
...
}
The function isleap(yyyy) returns 1 in a leap year, 0 otherwise. | Answer: Leap Year contributed by mojotoad DateTime offers an is_leap_year method for datetime objects.
They also provide leapsecond information via the DateTime::LeapSecond class, if you're into that.
Matt | Answer: Leap Year contributed by TheHobbit Well, may be... but your answer is false:).
Let's be precise: nowadays, your answer is right, but only since Gregorian reform, which has been take into account at different times in differents countries. Before that, and since 45BC, there was a leap year in every year divisible by 4 (NOTE: 45BC is year -44).
Even that isn't exatly true... At the beginning people did not understand what "once in 4 years" meant, and there was a period (between 45BC and 9BC) where there was a leap year every 3 years. Followed by a period (between 8BC and 8AD) where there was no leapyear at all.
See
the
Calendar FAQ
.
TheHobbit | Answer: Leap Year contributed by Sol-Invictus The exact dates when countries (that use the Western calendar) adopted the Gregorian version varies. See this section of the Calendar FAQ |
Please (register and) log in if you wish to add an answer
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|