onmyway133 / ISO8601

πŸŽ— Super lightweight ISO8601 Date Formatter in Swift

Home Page:https://onmyway133.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ISO8601

❀️ Support my apps ❀️

β€οΈβ€οΈπŸ˜‡πŸ˜πŸ€˜β€οΈβ€οΈ

ISO8601 in Swift

Version Carthage Compatible License Platform

Description

My answer on How do I get ISO 8601 date in iOS?

Usage

Formatter

Create a new formatter

var config = Config()
config.timeZoneIdentifier = " +0000"
let formatter = Formatter(config: config)

or use the default

Formatter.shared

Convert string to date

Formatter.shared.date(string: "2016-04-08T10:25:30Z")		// extended format with Z
Formatter.shared.date(string: "20160408 10:25:30Z")			// basic format with Z
Formatter.shared.date(string: "2016-04-08 112530 +010000")	// extended format with timezone offset
Formatter.shared.date(string: "2016-04-08 202530GMT+1000")	// extended format with GMT
Formatter.shared.date(string: "2016-04-08T10:25:30.000Z")	// milliseconds

Convert date to string

let date = Date(timeIntervalSince1970: 1460111130)
Formatter.shared.string(date: date) // 2016-04-08T10:25:30Z	// timezone Z

Installation

ISO8601 is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ISO8601', git: 'https://github.com/onmyway133/ISO8601'

ISO8601 is also available through Carthage. To install just write into your Cartfile:

github "onmyway133/ISO8601"

Author

Khoa Pham, onmyway133@gmail.com

Contributing

We would love you to contribute to ISO8601, check the CONTRIBUTING file for more info.

License

ISO8601 is available under the MIT license. See the LICENSE file for more info.

About

πŸŽ— Super lightweight ISO8601 Date Formatter in Swift

https://onmyway133.com

License:Other


Languages

Language:Swift 88.6%Language:Ruby 11.4%