Issue #1 resolved

'PnW' durations are not supported

Pedro Romano
created an issue

ISO 8601 allows durations with the format PnW for a given number of weeks, but aniso8601 doesn't support these.

Comments (5)

  1. Brandon Nielsen repo owner
    • marked as bug

    I can confirm the issue. Sample output shown below:

    >>> import aniso8601
    >>> aniso8601.parse_duration('P1W')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "aniso8601/duration.py", line 37, in parse_duration
        return parse_duration_combined(isodurationstr)
      File "aniso8601/duration.py", line 120, in parse_duration_combined
        datepart, timepart = durationstr[1:].split('T') #We skip the 'P'
    ValueError: need more than 1 value to unpack
    

    Expected result would be:

    >>> import aniso8601
    >>> aniso8601.parse_duration('P1W')
    datetime.timedelta(7)
    
  2. Log in to comment