Simple and intuitive time formatting using clock emoji.
- Platforms:
- macOS 10.9+
- iOS 8.0+
- watchOS 2.0+
- tvOS 9.0+
- Linux
- Xcode 7.3 and 8.0 beta 6
- Swift 2.2 and 3.0 preview 6
The Swift Package Manager is a decentralized dependency manager for Swift.
-
Add the project to your
Package.swift
.import PackageDescription let package = Package( name: "MyAwesomeProject", dependencies: [ .Package(url: "https://github.com/nvzqz/Clockmoji.git", majorVersion: 1) ] )
-
Import the Clockmoji module.
import Clockmoji
CocoaPods is a centralized dependency manager for Objective-C and Swift. Go here to learn more.
-
Add the project to your Podfile.
use_frameworks! pod 'Clockmoji', '~> 1.0.0'
If you want to be on the bleeding edge, replace the last line with:
pod 'Clockmoji', :git => 'https://github.com/nvzqz/Clockmoji.git'
-
Run
pod install
and open the.xcworkspace
file to launch Xcode. -
Import the Clockmoji framework.
import Clockmoji
Carthage is a decentralized dependency manager for Objective-C and Swift.
-
Add the project to your Cartfile.
github "nvzqz/Clockmoji"
-
Run
carthage update
and follow the additional steps in order to add Clockmoji to your project. -
Import the Clockmoji framework.
import Clockmoji
Simply add the contents of the Sources
folder into your project.
The ClockFace
enum features twenty-four cases for each clock emoji available.
A ClockFace
can be created from a time.
let tenOClock = ClockFace(time: 10)
let sixThirty = ClockFace(time: 6.5)
/// Rounds down in .5 intervals
let twoSomething = ClockFace(time: 2.4) // two: 🕑
/// Works with negatives
let twoOClock = ClockFace(time: -10) // equal to twoSomething
/// Works with large numbers
let crazyFace = ClockFace(time: 42352345432) // four: 🕓
The time interval for a ClockFace
can be easily retrieved using the
timeInterval
property.
ClockFace
can be initialized from a Date
.
let noon: Date = ...
let face = ClockFace(date: noon) // 🕛
A ClockFace
can also be created from the current date if no date is specified.
let face = ClockFace() // 🕥
ClockFace
has multiple properties that make formatting easy.
Printing a clock face directly will print its raw value.
ClockFace.tenThirty.name // "Ten thirty"
ClockFace.seven.nameWithAdditive // "Seven o'clock"
ClockFace.two.descriptionWithAdditive // "🕑 o'clock"
ClockFace.oneThirty.descriptionWithAdditive // "🕜"
ClockFace
conforms to Strideable
, allowing it to be used within a countable
range.
for face in ClockFace.one...ClockFace.three {
...
}
The advanced(by:)
method circles through faces in either a positive or negative direction.
ClockFace.two.advanced(by: 4) == ClockFace.two.advanced(by: 28)
ClockFace.two.advanced(by: 9) == ClockFace.two.advanced(by: -39)
Clockmoji is published under the MIT License.