Skip to content

Commit f791096

Browse files
committedFeb 1, 2022
docs: update usage and installation
1 parent a06d130 commit f791096

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed
 

‎README.md

+19-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Swift ISO 8601 Duration
22

3+
![](https://img.shields.io/badge/Swift-5.5-orange?style=flat&color=F05138)
34
![](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-orange?style=flat&color=F05138)
5+
![](https://img.shields.io/badge/Platform-iOS%20macOS%20tvOS%20watchOS-green?style=flat)
46

57
An ISO 8601 Duration parser for Swift. Inspired by the [Luxon](https://moment.github.io/luxon) duration object.
68

@@ -15,18 +17,21 @@ An ISO 8601 Duration parser for Swift. Inspired by the [Luxon](https://moment.gi
1517

1618
## Usage
1719

20+
Create a duration from an ISO 8601 string.
1821
```swift
19-
let duration = Duration(fromIso: "P2Y4M12DT5H34M48S")
22+
let duration = Duration(fromISO: "P2Y4M12DT5H34M48S")
2023

2124
// 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
3035
let dateComponents = duration.dateComponents
3136
```
3237

@@ -35,7 +40,9 @@ let dateComponents = duration.dateComponents
3540

3641
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.
3742

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:
44+
```swift
45+
dependencies: [
46+
.package(url: "https://github.com/longinius/duration.git", .upToNextMajor(from: "1.0.0"))
47+
]
4148
```

0 commit comments

Comments
 (0)