You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An ISO 8601 Duration parser for Swift. Inspired by the [Luxon](https://moment.github.io/luxon) duration object.
6
8
@@ -15,18 +17,21 @@ An ISO 8601 Duration parser for Swift. Inspired by the [Luxon](https://moment.gi
15
17
16
18
## Usage
17
19
20
+
Create a duration from an ISO 8601 string.
18
21
```swift
19
-
let duration =Duration(fromIso: "P2Y4M12DT5H34M48S")
22
+
let duration =Duration(fromISO: "P2Y4M12DT5H34M48S")
20
23
21
24
// Duration contains the parsed values
22
-
duration.years// 2
23
-
duration.months// 4
24
-
duration.days// 12
25
-
duration.hours// 5
26
-
duration.minutes// 34
27
-
duration.seconds// 48
28
-
29
-
// Create `DateComponents` object from `Duration`
25
+
duration.year// 2
26
+
duration.month// 4
27
+
duration.day// 12
28
+
duration.hour// 5
29
+
duration.minute// 34
30
+
duration.second// 48
31
+
```
32
+
33
+
Get a `DateComponents` object from duration.
34
+
```swift
30
35
let dateComponents = duration.dateComponents
31
36
```
32
37
@@ -35,7 +40,9 @@ let dateComponents = duration.dateComponents
35
40
36
41
The [Swift Package Manager](https://www.swift.org/package-manager/) is a tool for managing the distribution of Swift Code. It's integrated into the `swift` compiler.
37
42
38
-
To use `Duration`, simply add the following Package as dependency:
39
-
```
40
-
https://github.com/longinius/duration.git
43
+
To use `Duration` in your project, simply add this Package as dependency:
0 commit comments