Swiftpack.co - Package - std-swift/Time

Time

Provides clocks for keeping track of time

Importing

import Time
platforms: [
	.macOS(.v10_12)
],
dependencies: [
	.package(url: "https://github.com/std-swift/Time.git",
	         from: "1.0.0")
],
targets: [
	.target(
		name: "",
		dependencies: [
			"Time"
		]),
]

Using

Clock

  • .realtime Get the amount of time since the Epoch
  • .monotonic Get the amount of time since an arbitrary point
  • .process Get the amount of CPU time the process has been running for
  • .thread Get the amount of CPU time the thread has been running for

.now() -> Time returns the current time according to the Clock

Time

Contains .seconds and .nanoseconds

.view provides a Time.View which gives access to different representations of the time (.seconds, .milliseconds, .microseconds, .nanoseconds)

  • Time.distantPast is always in the past
  • Time.distantFuture is always in the future

Supported operations:

static func - (lhs: Time, rhs: Time) -> Timeout
static func + (lhs: Time, rhs: Timeout) -> Time
static func - (lhs: Time, rhs: Timeout) -> Time

Timeout

Represents a time interval in nanoseconds

.always
.never
.nanoseconds(_:)
.microseconds(_:)
.milliseconds(_:)
.seconds(_:)
.minutes(_:)
.hours(_:)

Supported operations:

static func + (lhs: Timeout, rhs: Timeout) -> Timeout
static func - (lhs: Timeout, rhs: Timeout) -> Timeout
static func * <T: BinaryInteger>(lhs: T, rhs: Timeout) -> Timeout
static func * <T: BinaryInteger>(lhs: Timeout, rhs: T) -> Timeout

Deadline

Represents a point in time relative to some fixed time in the past

  • .always A deadline in the past that is always reached
  • .never A deadline in the future that is never reached
  • .now() The current time

Supported operations:

var dispatchTime: DispatchTime

static func - (lhs: Deadline, rhs: Deadline) -> Timeout
static func + (lhs: Deadline, rhs: Timeout) -> Deadline
static func - (lhs: Deadline, rhs: Timeout) -> Deadline

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total: 2