Latest 1.0.0
Homepage https://github.com/nvzqz/Clockmoji
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0

Swift 2.2 | 3.0
Platforms
CocoaPods
Carthage
Swift Package Manager

Simple and intuitive time formatting using clock emoji.

Installation

Compatibility

  • 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

Install Using Swift Package Manager

The Swift Package Manager is a
decentralized dependency manager for Swift.

  1. 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)
        ]
    )
  2. Import the Clockmoji module.

    import Clockmoji

Install Using CocoaPods

CocoaPods is a centralized dependency manager for
Objective-C and Swift. Go here
to learn more.

  1. 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'
  2. Run pod install and open the .xcworkspace file to launch Xcode.

  3. Import the Clockmoji framework.

    import Clockmoji

Install Using Carthage

Carthage is a decentralized dependency
manager for Objective-C and Swift.

  1. Add the project to your Cartfile.

    github "nvzqz/Clockmoji"
  2. Run carthage update and follow the additional steps
    in order to add Clockmoji to your project.

  3. Import the Clockmoji framework.

    import Clockmoji

Install Manually

Simply add the contents of the Sources folder into your project.

Usage

The ClockFace enum features twenty-four cases for each clock emoji available.

Time

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.

Date

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()  // 🕥

Pretty Printing

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  // "🕜"

Strideable

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)

License

Clockmoji is published under the MIT License.

Latest podspec

{
    "name": "Clockmoji",
    "version": "1.0.0",
    "summary": "Simple and intuitive time formatting using clock emoji.",
    "homepage": "https://github.com/nvzqz/Clockmoji",
    "license": {
        "type": "MIT",
        "file": "LICENSE.md"
    },
    "authors": "Nikolai Vazquez",
    "social_media_url": "https://twitter.com/nikolaivazquez",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source": {
        "git": "https://github.com/nvzqz/Clockmoji.git",
        "tag": "v1.0.0"
    },
    "source_files": "Sources/*.swift"
}

Pin It on Pinterest

Share This