{"id":15038600,"url":"https://github.com/dominicegginton/nanoseconds","last_synced_at":"2025-04-10T01:22:26.389Z","repository":{"id":55144518,"uuid":"259797009","full_name":"dominicegginton/nanoseconds","owner":"dominicegginton","description":"Simple high-resolution timing for Swift","archived":false,"fork":false,"pushed_at":"2023-08-19T15:51:36.000Z","size":41,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-01T17:36:28.523Z","etag":null,"topics":["high-resolution","lightweight","nanoseconds","swift","time-interval","time-stamp"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dominicegginton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-29T01:48:10.000Z","updated_at":"2024-06-08T18:44:44.513Z","dependencies_parsed_at":"2024-06-08T18:54:44.939Z","dependency_job_id":null,"html_url":"https://github.com/dominicegginton/nanoseconds","commit_stats":{"total_commits":29,"total_committers":1,"mean_commits":29.0,"dds":0.0,"last_synced_commit":"34318d7a13b5b5013102fbe18b36b80368b4dcbd"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dominicegginton%2Fnanoseconds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dominicegginton%2Fnanoseconds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dominicegginton%2Fnanoseconds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dominicegginton%2Fnanoseconds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dominicegginton","download_url":"https://codeload.github.com/dominicegginton/nanoseconds/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248138342,"owners_count":21053853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["high-resolution","lightweight","nanoseconds","swift","time-interval","time-stamp"],"created_at":"2024-09-24T20:39:09.191Z","updated_at":"2025-04-10T01:22:26.353Z","avatar_url":"https://github.com/dominicegginton.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nanoseconds\n\nSimple high resolution time stamps for swift developers, along with helpful tools to work with them.\n\n## Key Features\n\n- High resolution time stamp\n- Built-in operators overloads\n- Useful extensions for unit conversion\n- Covert time intervals to a human readable strings\n- Linux compatible\n\n## Install\n\nInstall via the [**Swift Package Manger**](https://swift.org/package-manager/) by declaring **Nanoseconds** as a dependency in your  `Package.swift`:\n\n``` swift\n.package(url: \"https://github.com/dominicegginton/Nanoseconds\", from: \"1.0.0\")\n```\n\nRemember to add **Nanoseconds** to your target as a dependency.\n\n## Getting Started\n\n``` swift\nimport Foundation\nimport Nanoseconds\n\nlet start = Now()\nsleep(1)\nlet end = Now()\nlet duration = end - start\nprint(duration)  //=\u003e 1004222113.0\n```\n\n## Documentation\n\n#### Now\n\n```swift\n/**\n    A type that represents a point in time with nanosecond precision.\n*/\npublic struct Now {\n    /**\n        Creates a new `Now` instance.\n    */\n    public init()\n\n    /**\n        Compares two `Now` instances.\n        - Parameters:\n            - lhs: The first `Now` instance.\n            - rhs: The second `Now` instance.\n        - Returns: `true` if the first `Now` instance is less than the second `Now` instance.\n     */\n    public static func \u003c (lhs: Now, rhs: Now) -\u003e Bool\n\n    /**\n        Compares two `Now` instances.\n        - Parameters:\n            - lhs: The first `Now` instance.\n            - rhs: The second `Now` instance.\n        - Returns: `true` if the first `Now` instance is less than or equal to the second `Now` instance.\n     */\n    public static func \u003c= (lhs: Now, rhs: Now) -\u003e Bool\n\n    /**\n        Compares two `Now` instances.\n        - Parameters:\n            - lhs: The first `Now` instance.\n            - rhs: The second `Now` instance.\n        - Returns: `true` if the first `Now` instance is greater than the second `Now` instance.\n     */\n    public static func \u003e (lhs: Now, rhs: Now) -\u003e Bool\n\n    /**\n        Compares two `Now` instances.\n        - Parameters:\n            - lhs: The first `Now` instance.\n            - rhs: The second `Now` instance.\n        - Returns: `true` if the first `Now` instance is greater than or equal to the second `Now` instance.\n     */\n    public static func \u003e= (lhs: Now, rhs: Now) -\u003e Bool\n\n    /**\n        Compares two `Now` instances.\n        - Parameters:\n            - lhs: The first `Now` instance.\n            - rhs: The second `Now` instance.\n        - Returns: `true` if the first `Now` instance is equal to the second `Now` instance.\n     */\n    public static func == (lhs: Now, rhs: Now) -\u003e Bool\n\n    /**\n        Compares two `Now` instances.\n        - Parameters:\n            - lhs: The first `Now` instance.\n            - rhs: The second `Now` instance.\n        - Returns: `true` if the first `Now` instance is not equal to the second `Now` instance.\n     */\n    public static func != (lhs: Now, rhs: Now) -\u003e Bool\n    \n    /**\n        Subtract a `Now` instance from another `Now` instance.\n        - Parameters:\n            - lhs: The first `Now` instance.\n            - rhs: The second `Now` instance.\n        - Returns: The difference between the two `Now` instances.\n     */\n    public static func - (lhs: Now, rhs: Now) -\u003e TimeInterval\n\n    /**\n        Add a `Now` instance to another `Now` instance.\n        - Parameters:\n            - lhs: The first `Now` instance.\n            - rhs: The second `Now` instance.\n        - Returns: The sum of the two `Now` instances.\n     */\n    public static func + (lhs: Now, rhs: Now) -\u003e TimeInterval\n}\n```\n\n#### TimeInterval\n\n```swift\nextension TimeInterval {\n    /**\n        Creates a new `TimeInterval` from the given number of nanoseconds.\n        - Parameter nanoseconds: The number of nanoseconds.\n     */\n    public init (nanoseconds: Double)\n\n    /**\n        Creates a new `TimeInterval` from the given number of microseconds.\n        - Parameter microseconds: The number of microseconds.\n     */\n    public init (microseconds: Double)\n\n    /**\n        Creates a new `TimeInterval` from the given number of milliseconds.\n        - Parameter milliseconds: The number of milliseconds.\n     */\n    public init (milliseconds: Double)\n\n    /**\n        Creates a new `TimeInterval` from the given number of seconds.\n        - Parameter seconds: The number of seconds.\n     */\n    public init (seconds: Double)\n\n    /**\n        Creates a new `TimeInterval` from the given number of minutes.\n        - Parameter minutes: The number of minutes.\n     */\n    public init (minutes: Double)\n\n    /**\n        Creates a new `TimeInterval` from the given number of hours.\n        - Parameter hours: The number of hours.\n     */\n    public init (hours: Double)\n\n    /**\n        The number of nanoseconds in the `TimeInterval`.\n     */\n    public var nanoseconds: Double\n\n    /**\n        The number of microseconds in the `TimeInterval`.\n     */\n    public var microseconds: Double\n\n    /**\n        The number of milliseconds in the `TimeInterval`.\n     */\n    public var milliseconds: Double\n\n    /**\n        The number of seconds in the `TimeInterval`.\n     */\n    public var seconds: Double\n\n    /**\n        The number of minutes in the `TimeInterval`.\n     */\n    public var minutes: Double\n\n    /**\n        The number of hours in the `TimeInterval`.\n     */\n    public var hours: Double\n\n    /**\n        Covert the `TimeInterval` to a string.\n        The string will be in the format `[h]h [m]m [s]s`.\n        Only the largest unit of time will be displayed.\n     */\n    public var timeString: String\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdominicegginton%2Fnanoseconds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdominicegginton%2Fnanoseconds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdominicegginton%2Fnanoseconds/lists"}