A small Objective-C library that integrates Peter Hosey's ISO8601DateFormatter with RKValueTransformers
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Code
Tests
.gitignore
Gemfile
Gemfile.lock
ISO8601DateFormatterValueTransformer.podspec
LICENSE
Podfile
Podfile.lock
README.md
Rakefile

README.md

ISO8601DateFormatterValueTransformer

A small Objective-C library that integrates Peter Hosey's ISO8601DateFormatter with RKValueTransformers.

The implementation is done by adding RKValueTransforming conformance to the ISO8601DateFormatter via a category.

Examples

Usage

Basic usage is identical to all other RKValueTransforming classes.

#import "ISO8601DateValueTransformer.h"

RKISO8601DateFormatter *dateFormatter = [RKISO8601DateFormatter defaultISO8601DateFormatter];

// Transforming NSDate -> String
NSString *dateString = nil;
NSError *error = nil;
BOOL success = [dateFormatter transformValue:[NSDate date] toValue:&dateString ofClass:[NSDate class] error:&error];

// Transforming NSString -> NSDate
NSDate *date = nil;
success = [dateFormatter transformValue:@"2013-09-12T07:24:56-04:00" toValue:&dateString ofClass:[NSDate class] error:&error];

Configuration as Default Date Transformer

Adding the date formatter to the default value transformer at position 0 ensures that it is used ahead of all other NSString <-> NSDate value transformers.

#import "ISO8601DateValueTransformer.h"

RKISO8601DateFormatter *dateFormatter = [RKISO8601DateFormatter defaultISO8601DateFormatter];
[[RKValueTransformer defaultValueTransformer] insertValueTransformer:dateFormatter atIndex:0];

Credits

Blake Watters

License

ISO8601DateFormatterValueTransformer is available under the Apache 2 License. See the LICENSE file for more info.