String

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: https://www.w3.org/TR/xmlschema11-2/#duration

A more readable breakdown is here: http://www.datypic.com/sc/xsd/t-xsd_duration.html

  • 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.

    Declaration

    Swift

    var asXMLDuration: DateComponents! { get }

    Return Value

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