code: def daynum_to_date(daynum, max_days=1000000):
      
      if daynum is None:
          return None
      try:
          daycount = int(daynum)
      except ValueError:
          return None
  
      if daycount > max_days:
          # Using default: some time in the 48th century, clearly bogus.
          daycount = max_days
      return date(1970, 1, 1) + timedelta(daycount)
docs: Convert a number of days to a date. If it's out of range, default to a
      max date. If it is not a number (or a numeric string), return None. Using
      a max_days of more than 2932896 (9999-12-31) will throw an exception if the
      specified daynum exceeds the max.
      :param daynum: A number of days since Jan 1, 1970