All Projects → yaslab → ULID.swift

yaslab / ULID.swift

Licence: MIT license
Universally Unique Lexicographically Sortable Identifier (ULID) in Swift.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Labels

Projects that are alternatives of or similar to ULID.swift

ruby-ulid
generator, parser, optional monotonicity and manipulations for ULID
Stars: ✭ 19 (-36.67%)
Mutual labels:  ulid
go-ulid
Universally Unique Lexicographically Sortable Identifier (ULID) in Go - Please use https://github.com/oklog/ulid
Stars: ✭ 31 (+3.33%)
Mutual labels:  ulid
uuid-generator-plugin
An IntelliJ Idea plugin to generate UUID (Universally Unique Identifier), ULID (Universally Unique Lexicographically Sortable Identifier) and CUID (Collision Resistant Unique Identifier)
Stars: ✭ 30 (+0%)
Mutual labels:  ulid
ulid
Haskell implementation of ULIDs (Unique Lexicographically Sortable Identifiers)
Stars: ✭ 22 (-26.67%)
Mutual labels:  ulid
ulid
Universally Unique Lexicographically Sortable Identifier (ULID) in Crystal
Stars: ✭ 28 (-6.67%)
Mutual labels:  ulid
python-ulid
ULID implementation for Python
Stars: ✭ 177 (+490%)
Mutual labels:  ulid
Javascript
Universally Unique Lexicographically Sortable Identifier
Stars: ✭ 1,781 (+5836.67%)
Mutual labels:  ulid
tsid-creator
A Java library for generating Time Sortable Identifiers (TSID).
Stars: ✭ 16 (-46.67%)
Mutual labels:  ulid
ulid-creator
A Java library for generating Universally Unique Lexicographically Sortable Identifiers (ULID)
Stars: ✭ 38 (+26.67%)
Mutual labels:  ulid
pg ulid
Universally Unique Lexicographically Sortable Identifier (ULID) for PostgreSQL
Stars: ✭ 45 (+50%)
Mutual labels:  ulid
php-ulid
Universally Unique Lexicographically Sortable Identifier ported to PHP
Stars: ✭ 45 (+50%)
Mutual labels:  ulid
rulid.rs
Rust Universally Unique Lexicographically Sortable Identifier
Stars: ✭ 40 (+33.33%)
Mutual labels:  ulid

ULID.swift

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.2.0'

Carthage

github "yaslab/ULID.swift" ~> 1.2.0

Swift Package Manager

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

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].