➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Retro
Recipients Retro, belopolsky, eric.araujo, georg.brandl, pjenvey, r.david.murray, shadikka, terry.reedy
Date 2010-10-18.18:17:09
SpamBayes Score 4.1485753e-05
Marked as misclassified No
Message-id <[email protected]>
In-reply-to <[email protected]>
Content
else:
-->    ndays = (date(year, month + 1, 1) - first).days
    return first.weekday(), ndays

Oh my God! The line with a pointer is so ugly!

On Mon, Oct 18, 2010 at 7:59 PM, Alexander Belopolsky <
[email protected]> wrote:

>
> Alexander Belopolsky <[email protected]> added the comment:
>
> The most pedantic implementation of calendar.isleap() would be
>
> from datetime import date, timedelta
> def isleap(year):
>    return date(year, 3, 1) - date(year, 2, 1) == timedelta(29)
>
> Since python calendar only supports years in the range [1, 9999], the above
> will properly raise ValueError: year is out of range on negative or zero
> year.  This also guarantees that calendar module's notion of leap year is
> the same as that of datetime module.
>
> If this is found to be a worthwhile change, I would also rewrite monthrange
> as
>
> def monthrange(year, month):
>    first = date(year, month, 1)
>    if month == 12:
>        ndays = 31
>    else:
>        ndays = (date(year, month + 1, 1) - first).days
>    return first.weekday(), ndays
>
> ----------
>
> _______________________________________
> Python tracker <[email protected]>
> <http://bugs.python.org/issue10073>
> _______________________________________
>
Files
File name Uploaded
unnamed Retro, 2010-10-18.18:17:09
History
Date User Action Args
2010-10-18 18:17:11Retrosetrecipients: + Retro, georg.brandl, terry.reedy, belopolsky, pjenvey, eric.araujo, r.david.murray, shadikka
2010-10-18 18:17:09Retrolinkissue10073 messages
2010-10-18 18:17:09Retrocreate