# -*- coding: utf-8 -*- # Copyright (c) 2018, Brandon Nielsen # All rights reserved. # # This software may be modified and distributed under the terms # of the BSD license. See the LICENSE file for details. import datetime from aniso8601.date import parse_date from aniso8601.exceptions import ISOFormatError, RelativeValueError from aniso8601.time import parse_time from aniso8601 import compat def parse_duration(isodurationstr, relative=False): #Given a string representing an ISO 8601 duration, return a #datetime.timedelta (or dateutil.relativedelta.relativedelta #if relative=True) that matches the given duration. Valid formats are: # #PnYnMnDTnHnMnS (or any reduced precision equivalent) #PT