github.com/malcommac/SwiftDate

SwiftDate

Toolchain for parsing, manipulating and displaying dates and time zones on every Apple platform. Past four million downloads.

Community maintained·Swift·since 2015

In one look

let date = "2017-09-17T11:59:29+02:00".toISODate()
let later = date + 3.months - 2.days
let rome = later?.convertTo(region: Region(zone: .europeRome))

Foundation can do almost everything with dates, and it asks you to assemble four objects to do it. SwiftDate started as the wrapper I kept copying between projects: parse a string, move a date, render it in another region, without rebuilding a calendar every time.

What it does

  • Parse and format

    The formats you actually meet, ISO8601 and relative strings included, without assembling four objects first.

  • Math that keeps its region

    Calendar, locale and time zone travel together, so moving a date does not quietly change its meaning.

  • Every Apple platform, and Linux

    One API across iOS, macOS, watchOS, tvOS and server-side Swift.