Skip to content

Commit

Permalink
Merge branch 'minor-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
YOCKOW committed Sep 4, 2017
2 parents c48a92b + a68a2ae commit 4b7dd29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public struct TimeSpecification {
/* ... */
}
public enum Clock {
case Calendar
case System
case calendar
case system
public var timeSpecification: TimeSpecification? {
/* ... */
Expand All @@ -33,9 +33,9 @@ Then, you can use it in your project:
import TimeSpecification
func time(_ body:() -> Void) {
guard let start = Clock.System.timeSpecification else { return }
guard let start = Clock.system.timeSpecification else { return }
body()
guard let end = Clock.System.timeSpecification else { return }
guard let end = Clock.system.timeSpecification else { return }
let duration = end - start
print("\(duration)")
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/TimeSpecification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ extension TimeSpecification {
}
}
public enum Clock {
case Calendar
case System
case calendar
case system

public var timeSpecification: TimeSpecification? {
var c_timespec:CTimeSpec = CTimeSpec(tv_sec:0, tv_nsec:0)
Expand All @@ -115,11 +115,11 @@ public enum Clock {
var retval:CInt = -1

#if os(Linux)
clock_id = (self == .Calendar) ? CLOCK_REALTIME : CLOCK_MONOTONIC
clock_id = (self == .calendar) ? CLOCK_REALTIME : CLOCK_MONOTONIC
retval = clock_gettime(clock_id, &c_timespec)
#elseif os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
var clock_name: clock_serv_t = 0
clock_id = (self == .Calendar) ? CALENDAR_CLOCK : SYSTEM_CLOCK
clock_id = (self == .calendar) ? CALENDAR_CLOCK : SYSTEM_CLOCK
retval = host_get_clock_service(mach_host_self(), clock_id, &clock_name)
guard retval == 0 else { return nil }
retval = clock_get_time(clock_name, &c_timespec)
Expand Down

0 comments on commit 4b7dd29

Please sign in to comment.