Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
orchetect committed Sep 25, 2024
1 parent 1dd2b43 commit 691184e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions Sources/TimecodeKit/Documentation.docc/Math.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Multiplying timecode against timecode in order to produce a timecode result is n
Arithmetic operators are provided for convenience. These operators employ the ``Timecode/ValidationRule/wrapping`` validation rule in the event of underflows or overflows.

```swift
let tc1 = try "01:00:00:00".timecode(at: .fps23_976)
let tc2 = try "00:02:00:00".timecode(at: .fps23_976)
let tc1 = try Timecode(.string("01:00:00:00"), at: .fps23_976)
let tc2 = try Timecode(.string("00:02:00:00"), at: .fps23_976)

(tc1 + tc2).stringValue() // == "01:02:00:00"
(tc1 - tc2).stringValue() // == "00:58:00:00"
Expand All @@ -45,8 +45,8 @@ The right-hand operand may be a ``Timecode`` instance, or any time source value.
- `divide()` / `dividing()`

```swift
var tc1 = try "01:00:00:00".timecode(at: .fps23_976)
var tc2 = try "00:00:02:00".timecode(at: .fps23_976)
var tc1 = try Timecode(.string("01:00:00:00"), at: .fps23_976)
var tc2 = try Timecode(.string("00:00:02:00"), at: .fps23_976)

// in-place mutation
try tc1.add(tc2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Comparable protocol conformance.
Two ``Timecode`` instances can be compared linearly using common comparison operators.

```swift
try "01:00:00:00".timecode(at: .fps24)
== try "01:00:00:00".timecode(at: .fps24) // == true
try Timecode(.string("01:00:00:00"), at: .fps24)
== Timecode(.string("01:00:00:00"), at: .fps24) // == true

try "00:59:50:00".timecode(at: .fps24)
< "01:00:00:00".timecode(at: .fps24) // == true
try Timecode(.string("00:59:50:00"), at: .fps24)
< Timecode(.string("01:00:00:00"), at: .fps24) // == true

try "00:59:50:00".timecode(at: .fps24)
> "01:00:00:00".timecode(at: .fps24) // == false
try Timecode(.string("00:59:50:00"), at: .fps24)
> Timecode(.string("01:00:00:00"), at: .fps24) // == false
```

## Comparing using Timeline Context
Expand Down Expand Up @@ -85,7 +85,7 @@ Collections of ``Timecode`` can be sorted ascending or descending.

```swift
let timeline: [Timecode] = [ ... ]
let start = try "01:00:00:00".timecode(at: .fps24)
let start = try Timecode(.string("01:00:00:00"), at: .fps24)
let sorted = timeline.sorted(timelineStart: start) // ascending
let sorted = timeline.sorted(order: .reverse, timelineStart: start) // descending
```
Expand All @@ -94,15 +94,15 @@ These collections can also be tested for sort order:

```swift
let timeline: [Timecode] = [ ... ]
let start = try "01:00:00:00".timecode(at: .fps24)
let start = try Timecode(.string("01:00:00:00"), at: .fps24)
let isSorted: Bool = timeline.isSorted(timelineStart: start) // ascending
let isSorted: Bool = timeline.isSorted(order: .reverse, timelineStart: start) // descending
```

On newer systems, a `SortComparator` called ``TimecodeSortComparator`` is available as well.

```swift
let start = try "01:00:00:00".timecode(at: .fps24)
let start = try Timecode(.string("01:00:00:00"), at: .fps24)
let comparator = TimecodeSortComparator(timelineStart: start) // ascending
let comparator = TimecodeSortComparator(order: .reverse, timelineStart: start) // descending

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Forming a `Range` or `Stride` between two ``Timecode`` instances.
For simplicity, we will define the start and end timecodes beforehand.

```swift
let startTC = try "01:00:00:00".timecode(at: .fps24)
let endTC = try "01:00:00:10".timecode(at: .fps24)
let startTC = try Timecode(.string("01:00:00:00"), at: .fps24)
let endTC = try Timecode(.string("01:00:00:10"), at: .fps24)
```

## Range

Check if a timecode is contained within the range:

```swift
(startTC...endTC).contains(try "01:00:00:05".timecode(at: .fps24)) // == true
(startTC...endTC).contains(try "01:05:00:00".timecode(at: .fps24)) // == false
(startTC...endTC).contains(try Timecode(.string("01:00:00:05"), at: .fps24)) // == true
(startTC...endTC).contains(try Timecode(.string("01:05:00:00"), at: .fps24)) // == false
```

Iterate on each frame of the range:
Expand Down
2 changes: 1 addition & 1 deletion Sources/TimecodeKit/Timecode/Timecode Properties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension Timecode {
/// Timecode components can be get or set directly as instance properties.
///
/// ```swift
/// let tc = try "01:12:20:05".timecode(at: .fps23_976)
/// let tc = try Timecode(.string("01:12:20:05"), at: .fps23_976)
///
/// // get
/// tc.days // == 0
Expand Down

0 comments on commit 691184e

Please sign in to comment.