# CutBox.app

## Coverage Report

#### Created: 2024-03-12 03:40

    .../Source/App/Services/History/HistoryOffsetPredicateFactory.swift

    Line

    Count

    Source (jump to first uncovered line)

    1

    //

    2

    //  SimpleHistoryPredicateFactory.swift

    3

    //  CutBox

    4

    //

    5

    //  Created by Jason Milkins on 15/8/23.

    6

    //  Copyright © 2023 ocodo. All rights reserved.

    7

    //

    8

    9

    import Foundation

    10

    11

    2

    func historyOffsetPredicateFactory(offset: TimeInterval) -> (Date) -> Bool {

    12

    2

        guard offset != 0 else { fatalError("Error:Time offset 0 is invalid") }

    13

    2

        let cutoffDate = Date(timeIntervalSinceNow: -abs(offset))

    14

    2

    15

    2

        if offset > 0 {

    16

    5

            return { [cutoffDate] date in

    17

    5

                return date > cutoffDate

    18

    5

            }

    19

    1

        } else {

    20

    5

            return { [cutoffDate] date in

    21

    5

                return date < cutoffDate

    22

    5

            }

    23

    1

        }

    24

    0

    }

    25

    26

    7

    func historyOffsetPredicateFactory(offset: TimeInterval) -> (String) -> Bool {

    27

    7

        guard offset != 0 else { fatalError("Error:Time offset 0 is invalid") }

    28

    7

        let cutoffDate = iso8601Timestamp(fromDate: Date(timeIntervalSinceNow: -abs(offset)))

    29

    7

    30

    7

        if offset > 0 {

    31

    8

            return { [cutoffDate] itemTimestamp in itemTimestamp > cutoffDate }

    32

    4

        } else {

    33

    11

            return { [cutoffDate] itemTimestamp in itemTimestamp < cutoffDate }

    34

    4

        }

    35

    0

    }