On Tue, Apr 12, 2011 at 11:08 PM, Paul McNett <[email protected]> wrote:
> On 4/12/11 2:56 PM, Ed Leafe wrote:
>> import calendar
>> return calendar.isleap(year)
>
> Hmm, looking at the source, at least in Python 2.6.5, I think the isleap()
> function
> isn't as efficient as it could be. But it is one line. Here it is, converted
> to VFP
> if anyone wants it:
>
> {{{
>
> FUNC isleap(nYear):
> RETURN m.nYear % 4 == 0 AND (m.nYear % 100 != 0 OR m.nYear % 400 == 0)
>
> }}}
This is how C# does it (courtesy of Reflector):
public static bool IsLeapYear(int year)
{
if ((year < 1) || (year > 0x270f))
{
throw new ArgumentOutOfRangeException("year",
Environment.GetResourceString("ArgumentOutOfRange_Year"));
}
if ((year % 4) != 0)
{
return false;
}
if ((year % 100) == 0)
{
return ((year % 400) == 0);
}
return true;
}
--
Paul
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.