public extension String

This extension adds the capability to parse a String as an xs:duration (XML duration), returning the duration as a DateComponents Set.

The definition for duration is here:

A more readable breakdown is here:

  • This calculated property will examine the String, and will parse it for xsd:duration.

    If it can successfully parse the String as a properly-formatted duration, then it will return a DateComponents instance, with the duration therein.



    var asXMLDuration: DateComponents! { get }

    Return Value

    An instance of DateComponents, set to the duration. Nil, if the parse failed for any reason.