Latest 1.0.0
Homepage https://github.com/yaslab/ULID.swift
License MIT
Platforms ios 8.0, tvos 9.0, watchos 2.0, osx 10.9
Authors

Build Status
codecov

Implementation of ULID in Swift.

Usage

Generate ULID

import ULID

// Generate ULID using current time
let ulid = ULID()

// Get ULID string
let string: String = ulid.ulidString
// Get ULID binary data
let data: Data = ulid.ulidData

Parse ULID

import ULID

// Parse ULID string
let ulid = ULID(ulidString: "01D0YHEWR9WMPY4NNTPK1MR1TQ")!

// Get Timestamp as Date
let timestamp: Date = ulid.timestamp

Convert between ULID and UUID

Both ULID and UUID are 128 bit data, so you can convert strings to each other.

From ULID to UUID

import Foundation
import ULID

let ulid = ULID(ulidString: "01D132CXJVYQ7091KZPZR5WH1X")!
let uuid = UUID(uuid: ulid.ulid)
print(uuid.uuidString) // 01684626-765B-F5CE-0486-7FB7F05E443D

From UUID to ULID

import Foundation
import ULID

let uuid = UUID(uuidString: "01684626-765B-F5CE-0486-7FB7F05E443D")!
let ulid = ULID(ulid: uuid.uuid)
print(ulid.ulidString) // 01D132CXJVYQ7091KZPZR5WH1X

Installation

CocoaPods

pod 'ULID.swift', '~> 1.0.0'

Carthage

github "yaslab/ULID.swift" ~> 1.0.0

Swift Package Manager

.package(url: "https://github.com/yaslab/ULID.swift.git", .upToNextMinor(from: "1.0.0"))

License

ULID.swift is released under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ULID.swift",
    "version": "1.0.0",
    "license": {
        "type": "MIT"
    },
    "homepage": "https://github.com/yaslab/ULID.swift",
    "authors": {
        "Yasuhiro Hatta": "[email protected]"
    },
    "summary": "Universally Unique Lexicographically Sortable Identifier (ULID) in Swift.",
    "source": {
        "git": "https://github.com/yaslab/ULID.swift.git",
        "tag": "1.0.0"
    },
    "source_files": "Sources/ULID/*.swift",
    "platforms": {
        "ios": "8.0",
        "tvos": "9.0",
        "watchos": "2.0",
        "osx": "10.9"
    },
    "module_name": "ULID"
}

Pin It on Pinterest

Share This