refactor: use short if let syntax
An ISO 8601 Duration parser for Swift. Inspired by the Luxon Duration object.
Codable
DateComponents
Duration
Calendar
Create a duration from an ISO 8601 string.
let duration = Duration(fromISO: "P2Y4M12DT5H34M48S") // Duration contains the parsed values duration.year // 2 duration.month // 4 duration.day // 12 duration.hour // 5 duration.minute // 34 duration.second // 48
Get a DateComponents object from duration.
let dateComponents = duration.dateComponents
The Swift Package Manager is a tool for managing the distribution of Swift Code. It’s integrated into the swift compiler.
swift
To use Duration in your project, simply add this Package as dependency:
dependencies: [ .package(url: "https://github.com/longinius/swift-duration.git", .upToNextMajor(from: "1.0.0")) ]
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
Swift ISO 8601 Duration
An ISO 8601 Duration parser for Swift. Inspired by the Luxon Duration object.
Features
Codable
protocol.DateComponents
object fromDuration
.Calendar
to useDuration
likeDateComponents
.Usage
Create a duration from an ISO 8601 string.
Get a
DateComponents
object from duration.Installation
The Swift Package Manager is a tool for managing the distribution of Swift Code. It’s integrated into the
swift
compiler.To use
Duration
in your project, simply add this Package as dependency: