diff --git a/README.md b/README.md index 8097d55..a5f3903 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,13 @@ Library for printing time in Swatch .beat time. -More info [here](https://www.swatch.com/en_us/internet-time). +More info on Swatch Internet Time [here](https://www.swatch.com/en_us/internet-time). + +## Usage + +``` Swift +let nb = Beat() + +nb.int() // Gives ya back an Int +nb.text() // Gives ya back a String +``` diff --git a/Sources/Beat/Beat.swift b/Sources/Beat/Beat.swift index 3c54db6..e78ce51 100644 --- a/Sources/Beat/Beat.swift +++ b/Sources/Beat/Beat.swift @@ -2,7 +2,7 @@ import Foundation public struct Beat { fileprivate var db: Int - public init(_ epoch: Double) { + public init(_ epoch: Double = Date().timeIntervalSince1970) { let utc_1 = Int(epoch + 3600) let r = utc_1%86400 self.db = (Int(Double(r)/86.4)) diff --git a/Tests/BeatTests/BeatTests.swift b/Tests/BeatTests/BeatTests.swift index b69a4a1..ded053a 100644 --- a/Tests/BeatTests/BeatTests.swift +++ b/Tests/BeatTests/BeatTests.swift @@ -9,6 +9,11 @@ final class BeatTests: XCTestCase { XCTAssertGreaterThan(b.int(), 0) XCTAssertLessThan(b.int(), 1000) XCTAssertEqual(b.text(), "997") + + // now beat + let nb = Beat() + XCTAssertGreaterThan(nb.int(), 0) + XCTAssertLessThan(nb.int(), 1000) } static var allTests = [