Stock Maximum Pro

ISO8601DurationFormatter

I really had no idea what formatted strings like PT0S, P0D or PT5M30S meant when I first encountered them… And I am not alone, almost all developers who join the team ask the same question: what are these?

Well, did you know that the ISO8601 standard, commonly used to format dates, also has a duration component?

From https://en.wikipedia.org/wiki/ISO_8601#Durations:

Even though the Foundation framework in Swift offers the ISO8601DateFormatter, it obviously doesn’t support durations and since we needed to serialize/deserialize durations for a project, I ended up writing a small library that does just that.

Github repo: https://github.com/cyrilchandelier/ISO8601DurationFormatter


Leave a Reply

Your email address will not be published. Required fields are marked *