constructing Datetime objects with ISO week numbers

an old problem, but almost no library implements it, so here is my shot at it in python:

import datetime

def DateTimeFromIsoWeek(year, isoweek=1):
   """DateTimeFromIsoWeek(year,isoweek=1)

       Returns a DateTime instance pointing to the given ISO week/year
       The weekday defaults to 4, which corresponds to Thursday in the
       ISO numbering. The time part is set to 00:00:00.
   """
   # anyone knows what assertions could be done for the year?
 assert 0 < isoweek < 54
 # start stupidly with 1st January of the given year:
 d = datetime.datetime(year, 1, 1, 0, 0, 0)
 # what weekday is this?
 dow = d.isocalendar()[2]
 # advance to next thursday, if not already on a thursday:
 if dow < 4: # if we are in monday - wednesday:
    d += datetime.timedelta(7 - dow - 3)
 elif dow > 4: # if we are in friday - sunday
    d += datetime.timedelta(7 - dow + 4)
 # advance to the given week:
 d += datetime.timedelta((isoweek-1) * 7)
 if isoweek == 53: # this might be a user error, not all years have 53 weeks, so check it
    y = d.isocalendar()[0]
 if y != year: # we ended in a different year -> the given year only has 52 weeks!
    raise Exception, "The year '%i' does not have an ISO week '%i'" % (year, isoweek)

 return d