[issue14423] Getting the starting date of iso week from a week number and a year.

Alexander Belopolsky report at bugs.python.org
Tue Apr 10 15:32:30 CEST 2012


Alexander Belopolsky <alexander.belopolsky at gmail.com> added the comment:

On Tue, Apr 10, 2012 at 6:44 AM, Antoine Pitrou <report at bugs.python.org> wrote:
> It's so easy that the patch isn't a one-liner and it seems to still have
> bugs wrt. intended behaviour.

Unless I miss something, the inverse to isocalendar() is simply

from datetime import *

def fromiso(year, week, day):
    d = date(year, 1, 4)
    return d + timedelta((week - 1) * 7 + day - d.isoweekday())

At least it works in my testing:

(2012, 15, 2)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14423>
_______________________________________


More information about the Python-bugs-list mailing list