All Projects → soffes → Iso8601

soffes / Iso8601

Licence: mit
ISO8601 date parser and writer

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Iso8601

Sqift
Powerful Swift wrapper for SQLite
Stars: ✭ 119 (-44.13%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Cocoalumberjack
A fast & simple, yet powerful & flexible logging framework for Mac and iOS
Stars: ✭ 12,584 (+5807.98%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Xcglogger
A debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number.
Stars: ✭ 3,710 (+1641.78%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Sdwebimagewebpcoder
A WebP coder plugin for SDWebImage, use libwebp
Stars: ✭ 101 (-52.58%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-25.82%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Web3.swift
A pure swift Ethereum Web3 library
Stars: ✭ 295 (+38.5%)
Mutual labels:  tvos, watchos, cocoapods, carthage
L10n Swift
Localization of the application with ability to change language "on the fly" and support for plural form in any language.
Stars: ✭ 177 (-16.9%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Swiftframeworktemplate
A template for new Swift iOS / macOS / tvOS / watchOS Framework project ready with travis-ci, cocoapods, Carthage, SwiftPM and a Readme file
Stars: ✭ 527 (+147.42%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Color
Color utilities for macOS, iOS, tvOS, and watchOS
Stars: ✭ 145 (-31.92%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Ducttape
📦 KeyPath dynamicMemberLookup based syntax sugar for Swift.
Stars: ✭ 138 (-35.21%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+4926.29%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Swiftyattributes
A Swifty API for attributed strings
Stars: ✭ 1,303 (+511.74%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Datez
📆 Breeze through Date, DateComponents, and TimeInterval with Swift!
Stars: ✭ 254 (+19.25%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Functionkit
A framework for functional types and operations designed to fit naturally into Swift.
Stars: ✭ 302 (+41.78%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Guitar
A Cross-Platform String and Regular Expression Library written in Swift.
Stars: ✭ 641 (+200.94%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Swiftlinkpreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images.
Stars: ✭ 1,216 (+470.89%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Contentful.swift
A delightful Swift interface to Contentful's content delivery API.
Stars: ✭ 132 (-38.03%)
Mutual labels:  tvos, watchos, cocoapods, carthage
Diff
Simple diff library in pure Swift
Stars: ✭ 110 (-48.36%)
Mutual labels:  tvos, watchos, carthage
Predicateflow
Write amazing, strong-typed and easy-to-read NSPredicate.
Stars: ✭ 98 (-53.99%)
Mutual labels:  tvos, watchos, cocoapods
Randomkit
Random data generation in Swift
Stars: ✭ 1,458 (+584.51%)
Mutual labels:  watchos, cocoapods, carthage

ISO8601

Version Build Status Carthage compatible CocoaPods compatible

Fast ISO8601 date parser and writer for iOS & Mac.

Installation

Carthage is the recommended way to install ISO8601. Add the following to your Cartfile:

github "soffes/ISO8601"

You can also install with CocoaPods:

pod 'ISO8601'

For manual installation, I recommend adding the project as a subproject to your project or workspace and adding the framework as a target dependency.

Usage

First, import the appropriate header:

@import ISO8601; // Use #import <ISO8601/ISO8601.h> if you're using CocoaPods

This library uses NSDateComponents for reading and writing. Here's an example:

// Reading
NSDateComponents *dateComponents = [ISO8601Serialization dateComponentsForString:@"1999-05-19T23:55:21+09:00"];

// Writing
NSString *ISO8601String = [ISO8601Serialization stringForDateComponents:dateComponents];

There is an NSDate category for convenient conversion:

// Reading
NSDate *date = [NSDate dateWithISO8601String:@"1999-05-19T23:55:21+09:00"];

// Writing
NSString *ISO8601String = [date ISO8601String];

If you require more control over conversion or need to know the input time zone, you can use the advanced methods the category provides:

// Reading
NSTimeZone *timeZone;
NSDate *date = [NSDate dateWithISO8601String:@"1999-05-19T23:55:21+09:00" timeZone:&timeZone usingCalendar:calendarOrNil];

// Writing
NSString *ISO8601String = [date ISO8601StringWithTimeZone:timeZoneOrNil usingCalendar:calendarOrNil];

Notes

NSDateComponents is the core data structure because NSDate doesn't perserve time zone information well.

It's worth noting that a value in the NSDateComponents will be nil if it is not in the input string. For example, 1999-05-19T23:55:21 will have a nil time zone, but 1999-05-19T23:55:21+00:00 and 1999-05-19T23:55:21Z will have a UTC time zone.

The +[NSDate dateWithISO8601String:] category will always return a UTC date. If you want a date in another time zone, you should use +[NSDate ISO8601StringWithTimeZone:usingCalendar:] (you may pass nil for the calendar parameter to use the current calendar).

Enjoy.

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].