mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-24 04:46:01 +08:00
Drop ISO8601DateFormatter dependency since it has a time zone handling bug and switch to RK specific fork. fixes #971
* ARCify the ISO8601DateFormatter
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#import "RKRelationshipMapping.h"
|
||||
#import "RKPropertyInspector.h"
|
||||
#import "RKLog.h"
|
||||
#import "ISO8601DateFormatter.h"
|
||||
#import "RKISO8601DateFormatter.h"
|
||||
#import "RKAttributeMapping.h"
|
||||
#import "RKRelationshipMapping.h"
|
||||
|
||||
@@ -356,7 +356,7 @@ static NSDateFormatter *preferredDateFormatter = nil;
|
||||
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
|
||||
[self addDefaultDateFormatter:numberFormatter];
|
||||
|
||||
ISO8601DateFormatter *isoFormatter = [[ISO8601DateFormatter alloc] init];
|
||||
RKISO8601DateFormatter *isoFormatter = [[RKISO8601DateFormatter alloc] init];
|
||||
isoFormatter.parsesStrictly = YES;
|
||||
[self addDefaultDateFormatter:isoFormatter];
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// This is a forked copy of the ISO8601DateFormatter
|
||||
|
||||
/*ISO8601DateFormatter.h
|
||||
*
|
||||
*Created by Peter Hosey on 2009-04-11.
|
||||
@@ -25,24 +27,24 @@
|
||||
*Week format is YYYY-Www-D, where ww ranges from 1 to 53 (the 'W' is literal) and D ranges from 1 to 7; for example, 2009-W05-07.
|
||||
*/
|
||||
enum {
|
||||
ISO8601DateFormatCalendar,
|
||||
ISO8601DateFormatOrdinal,
|
||||
ISO8601DateFormatWeek,
|
||||
RKISO8601DateFormatCalendar,
|
||||
RKISO8601DateFormatOrdinal,
|
||||
RKISO8601DateFormatWeek,
|
||||
};
|
||||
typedef NSUInteger ISO8601DateFormat;
|
||||
typedef NSUInteger RKISO8601DateFormat;
|
||||
|
||||
//The default separator for time values. Currently, this is ':'.
|
||||
extern unichar ISO8601DefaultTimeSeparatorCharacter;
|
||||
extern unichar RKISO8601DefaultTimeSeparatorCharacter;
|
||||
|
||||
@interface ISO8601DateFormatter: NSFormatter
|
||||
@interface RKISO8601DateFormatter: NSFormatter
|
||||
{
|
||||
NSString *lastUsedFormatString;
|
||||
NSDateFormatter *unparsingFormatter;
|
||||
|
||||
|
||||
NSCalendar *parsingCalendar, *unparsingCalendar;
|
||||
|
||||
|
||||
NSTimeZone *defaultTimeZone;
|
||||
ISO8601DateFormat format;
|
||||
RKISO8601DateFormat format;
|
||||
unichar timeSeparator;
|
||||
BOOL includeTime;
|
||||
BOOL parsesStrictly;
|
||||
@@ -69,7 +71,7 @@ extern unichar ISO8601DefaultTimeSeparatorCharacter;
|
||||
|
||||
#pragma mark Unparsing
|
||||
|
||||
@property ISO8601DateFormat format;
|
||||
@property RKISO8601DateFormat format;
|
||||
@property BOOL includeTime;
|
||||
@property unichar timeSeparator;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// This is a forked copy of the ISO8601DateFormatter
|
||||
|
||||
/*ISO8601DateFormatter.m
|
||||
*
|
||||
*Created by Peter Hosey on 2009-04-11.
|
||||
@@ -5,7 +7,7 @@
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ISO8601DateFormatter.h"
|
||||
#import "RKISO8601DateFormatter.h"
|
||||
#import "RKLog.h"
|
||||
|
||||
// Set Logging Component
|
||||
@@ -15,19 +17,19 @@
|
||||
#ifndef DEFAULT_TIME_SEPARATOR
|
||||
# define DEFAULT_TIME_SEPARATOR ':'
|
||||
#endif
|
||||
unichar ISO8601DefaultTimeSeparatorCharacter = DEFAULT_TIME_SEPARATOR;
|
||||
unichar RKISO8601DefaultTimeSeparatorCharacter = DEFAULT_TIME_SEPARATOR;
|
||||
|
||||
//Unicode date formats.
|
||||
#define ISO_CALENDAR_DATE_FORMAT @"yyyy-MM-dd"
|
||||
//#define ISO_WEEK_DATE_FORMAT @"YYYY-'W'ww-ee" //Doesn't actually work because NSDateComponents counts the weekday starting at 1.
|
||||
#define ISO_ORDINAL_DATE_FORMAT @"yyyy-DDD"
|
||||
#define ISO_TIME_FORMAT @"HH:mm:ss"
|
||||
#define ISO_TIME_WITH_TIMEZONE_FORMAT ISO_TIME_FORMAT @"Z"
|
||||
#define RK_ISOCALENDAR_DATE_FORMAT @"yyyy-MM-dd"
|
||||
//#define RK_ISOWEEK_DATE_FORMAT @"YYYY-'W'ww-ee" //Doesn't actually work because NSDateComponents counts the weekday starting at 1.
|
||||
#define RK_ISOORDINAL_DATE_FORMAT @"yyyy-DDD"
|
||||
#define RK_ISOTIME_FORMAT @"HH:mm:ss"
|
||||
#define RK_ISOTIME_WITH_TIMEZONE_FORMAT RK_ISOTIME_FORMAT @"Z"
|
||||
//printf formats.
|
||||
#define ISO_TIMEZONE_UTC_FORMAT @"Z"
|
||||
#define ISO_TIMEZONE_OFFSET_FORMAT @"%+.2ld%.2ld"
|
||||
#define RK_ISOTIMEZONE_UTC_FORMAT @"Z"
|
||||
#define RK_ISOTIMEZONE_OFFSET_FORMAT @"%+.2ld%.2ld"
|
||||
|
||||
@interface ISO8601DateFormatter(UnparsingPrivate)
|
||||
@interface RKISO8601DateFormatter(UnparsingPrivate)
|
||||
|
||||
- (NSString *) replaceColonsInString:(NSString *)timeFormat withTimeSeparator:(unichar)timeSep;
|
||||
|
||||
@@ -38,7 +40,7 @@ unichar ISO8601DefaultTimeSeparatorCharacter = DEFAULT_TIME_SEPARATOR;
|
||||
|
||||
static NSMutableDictionary *timeZonesByOffset;
|
||||
|
||||
@implementation ISO8601DateFormatter
|
||||
@implementation RKISO8601DateFormatter
|
||||
|
||||
+ (void) initialize {
|
||||
if (!timeZonesByOffset) {
|
||||
@@ -47,13 +49,11 @@ static NSMutableDictionary *timeZonesByOffset;
|
||||
}
|
||||
|
||||
+ (void) purgeGlobalCaches {
|
||||
NSMutableDictionary *oldCache = timeZonesByOffset;
|
||||
timeZonesByOffset = nil;
|
||||
[oldCache release];
|
||||
}
|
||||
|
||||
- (NSCalendar *) makeCalendarWithDesiredConfiguration {
|
||||
NSCalendar *calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
|
||||
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
|
||||
calendar.firstWeekday = 2; //Monday
|
||||
calendar.timeZone = [NSTimeZone defaultTimeZone];
|
||||
return calendar;
|
||||
@@ -61,33 +61,21 @@ static NSMutableDictionary *timeZonesByOffset;
|
||||
|
||||
- (id) init {
|
||||
if ((self = [super init])) {
|
||||
parsingCalendar = [[self makeCalendarWithDesiredConfiguration] retain];
|
||||
unparsingCalendar = [[self makeCalendarWithDesiredConfiguration] retain];
|
||||
parsingCalendar = [self makeCalendarWithDesiredConfiguration];
|
||||
unparsingCalendar = [self makeCalendarWithDesiredConfiguration];
|
||||
|
||||
format = ISO8601DateFormatCalendar;
|
||||
timeSeparator = ISO8601DefaultTimeSeparatorCharacter;
|
||||
format = RKISO8601DateFormatCalendar;
|
||||
timeSeparator = RKISO8601DefaultTimeSeparatorCharacter;
|
||||
includeTime = NO;
|
||||
parsesStrictly = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (void) dealloc {
|
||||
[defaultTimeZone release];
|
||||
|
||||
[unparsingFormatter release];
|
||||
[lastUsedFormatString release];
|
||||
[parsingCalendar release];
|
||||
[unparsingCalendar release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@synthesize defaultTimeZone;
|
||||
- (void) setDefaultTimeZone:(NSTimeZone *)tz {
|
||||
if (defaultTimeZone != tz) {
|
||||
[defaultTimeZone release];
|
||||
defaultTimeZone = [tz retain];
|
||||
|
||||
defaultTimeZone = tz;
|
||||
unparsingCalendar.timeZone = defaultTimeZone;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +98,7 @@ static BOOL is_leap_year(NSUInteger year);
|
||||
*YYYY-MM-DD
|
||||
*YYYY-MM
|
||||
*YYYY
|
||||
*YY //century
|
||||
*YY //century
|
||||
* //Implied century: YY is 00-99
|
||||
* YYMMDD
|
||||
* YY-MM-DD
|
||||
@@ -161,7 +149,7 @@ static BOOL is_leap_year(NSUInteger year);
|
||||
- (NSDateComponents *) dateComponentsFromString:(NSString *)string timeZone:(out NSTimeZone **)outTimeZone range:(out NSRange *)outRange {
|
||||
NSDate *now = [NSDate date];
|
||||
|
||||
NSDateComponents *components = [[[NSDateComponents alloc] init] autorelease];
|
||||
NSDateComponents *components = [[NSDateComponents alloc] init];
|
||||
NSDateComponents *nowComponents = [parsingCalendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:now];
|
||||
|
||||
NSUInteger
|
||||
@@ -187,7 +175,7 @@ static BOOL is_leap_year(NSUInteger year);
|
||||
BOOL strict = self.parsesStrictly;
|
||||
unichar timeSep = self.timeSeparator;
|
||||
|
||||
if (strict) timeSep = ISO8601DefaultTimeSeparatorCharacter;
|
||||
if (strict) timeSep = RKISO8601DefaultTimeSeparatorCharacter;
|
||||
NSAssert(timeSep != '\0', @"Time separator must not be NUL.");
|
||||
|
||||
BOOL isValidDate = ([string length] > 0U);
|
||||
@@ -650,7 +638,7 @@ static BOOL is_leap_year(NSUInteger year);
|
||||
|
||||
- (NSString *) replaceColonsInString:(NSString *)timeFormat withTimeSeparator:(unichar)timeSep {
|
||||
if (timeSep != ':') {
|
||||
NSMutableString *timeFormatMutable = [[timeFormat mutableCopy] autorelease];
|
||||
NSMutableString *timeFormatMutable = [timeFormat mutableCopy];
|
||||
[timeFormatMutable replaceOccurrencesOfString:@":"
|
||||
withString:[NSString stringWithCharacters:&timeSep length:1U]
|
||||
options:NSBackwardsSearch | NSLiteralSearch
|
||||
@@ -668,30 +656,25 @@ static BOOL is_leap_year(NSUInteger year);
|
||||
|
||||
- (NSString *) stringFromDate:(NSDate *)date timeZone:(NSTimeZone *)timeZone {
|
||||
switch (self.format) {
|
||||
case ISO8601DateFormatCalendar:
|
||||
return [self stringFromDate:date formatString:ISO_CALENDAR_DATE_FORMAT timeZone:timeZone];
|
||||
case ISO8601DateFormatWeek:
|
||||
case RKISO8601DateFormatCalendar:
|
||||
return [self stringFromDate:date formatString:RK_ISOCALENDAR_DATE_FORMAT timeZone:timeZone];
|
||||
case RKISO8601DateFormatWeek:
|
||||
return [self weekDateStringForDate:date timeZone:timeZone];
|
||||
case ISO8601DateFormatOrdinal:
|
||||
return [self stringFromDate:date formatString:ISO_ORDINAL_DATE_FORMAT timeZone:timeZone];
|
||||
case RKISO8601DateFormatOrdinal:
|
||||
return [self stringFromDate:date formatString:RK_ISOORDINAL_DATE_FORMAT timeZone:timeZone];
|
||||
default:
|
||||
[NSException raise:NSInternalInconsistencyException format:@"self.format was %ld, not calendar (%d), week (%d), or ordinal (%d)", (unsigned long) self.format, ISO8601DateFormatCalendar, ISO8601DateFormatWeek, ISO8601DateFormatOrdinal];
|
||||
[NSException raise:NSInternalInconsistencyException format:@"self.format was %ld, not calendar (%d), week (%d), or ordinal (%d)", (unsigned long) self.format, RKISO8601DateFormatCalendar, RKISO8601DateFormatWeek, RKISO8601DateFormatOrdinal];
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *) stringFromDate:(NSDate *)date formatString:(NSString *)dateFormat timeZone:(NSTimeZone *)timeZone {
|
||||
if (includeTime)
|
||||
dateFormat = [dateFormat stringByAppendingFormat:@"'T'%@", [self replaceColonsInString:ISO_TIME_FORMAT withTimeSeparator:self.timeSeparator]];
|
||||
|
||||
unparsingCalendar.timeZone = timeZone;
|
||||
dateFormat = [dateFormat stringByAppendingFormat:@"'T'%@", [self replaceColonsInString:RK_ISOTIME_FORMAT withTimeSeparator:self.timeSeparator]];
|
||||
|
||||
if (dateFormat != lastUsedFormatString) {
|
||||
[unparsingFormatter release];
|
||||
unparsingFormatter = nil;
|
||||
|
||||
[lastUsedFormatString release];
|
||||
lastUsedFormatString = [dateFormat retain];
|
||||
lastUsedFormatString = dateFormat;
|
||||
}
|
||||
|
||||
if (!unparsingFormatter) {
|
||||
@@ -701,19 +684,22 @@ static BOOL is_leap_year(NSUInteger year);
|
||||
unparsingFormatter.calendar = unparsingCalendar;
|
||||
}
|
||||
|
||||
unparsingCalendar.timeZone = timeZone;
|
||||
unparsingFormatter.timeZone = timeZone;
|
||||
NSString *str = [unparsingFormatter stringForObjectValue:date];
|
||||
|
||||
if (includeTime) {
|
||||
NSInteger offset = [timeZone secondsFromGMT];
|
||||
offset /= 60; //bring down to minutes
|
||||
if (offset == 0)
|
||||
str = [str stringByAppendingString:ISO_TIMEZONE_UTC_FORMAT];
|
||||
str = [str stringByAppendingString:RK_ISOTIMEZONE_UTC_FORMAT];
|
||||
else
|
||||
str = [str stringByAppendingFormat:ISO_TIMEZONE_OFFSET_FORMAT, (long) (offset / 60), (long) (offset % 60)];
|
||||
str = [str stringByAppendingFormat:RK_ISOTIMEZONE_OFFSET_FORMAT, (long) (offset / 60), (long) (offset % 60)];
|
||||
}
|
||||
|
||||
//Undo the change we made earlier
|
||||
unparsingCalendar.timeZone = self.defaultTimeZone;
|
||||
unparsingFormatter.timeZone = self.defaultTimeZone;
|
||||
|
||||
return str;
|
||||
}
|
||||
@@ -786,12 +772,10 @@ static BOOL is_leap_year(NSUInteger year);
|
||||
if(includeTime) {
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
unichar timeSep = self.timeSeparator;
|
||||
if (!timeSep) timeSep = ISO8601DefaultTimeSeparatorCharacter;
|
||||
formatter.dateFormat = [self replaceColonsInString:ISO_TIME_WITH_TIMEZONE_FORMAT withTimeSeparator:timeSep];
|
||||
if (!timeSep) timeSep = RKISO8601DefaultTimeSeparatorCharacter;
|
||||
formatter.dateFormat = [self replaceColonsInString:RK_ISOTIME_WITH_TIMEZONE_FORMAT withTimeSeparator:timeSep];
|
||||
|
||||
timeString = [formatter stringForObjectValue:date];
|
||||
|
||||
[formatter release];
|
||||
} else
|
||||
timeString = @"";
|
||||
|
||||
@@ -29,7 +29,6 @@ Pod::Spec.new do |s|
|
||||
s.subspec 'ObjectMapping' do |os|
|
||||
os.header_dir = 'RestKit/ObjectMapping'
|
||||
os.source_files = 'Code/ObjectMapping'
|
||||
os.dependency 'ISO8601DateFormatter', '>= 0.6'
|
||||
end
|
||||
|
||||
s.subspec 'Network' do |ns|
|
||||
|
||||
@@ -502,6 +502,12 @@
|
||||
25CAAA9515254E7800CAE5D7 /* ArrayOfHumans.json in Resources */ = {isa = PBXBuildFile; fileRef = 25CAAA9315254E7800CAE5D7 /* ArrayOfHumans.json */; };
|
||||
25CC5C59161DDADD0008BD21 /* RKResponseDescriptorTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25CC5C58161DDADD0008BD21 /* RKResponseDescriptorTest.m */; };
|
||||
25CC5C5A161DDADD0008BD21 /* RKResponseDescriptorTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25CC5C58161DDADD0008BD21 /* RKResponseDescriptorTest.m */; };
|
||||
25CDA0DC161E7ED400F583F3 /* RKISO8601DateFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 25CDA0DA161E7ED400F583F3 /* RKISO8601DateFormatter.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
25CDA0DD161E7ED400F583F3 /* RKISO8601DateFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 25CDA0DA161E7ED400F583F3 /* RKISO8601DateFormatter.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
25CDA0DE161E7ED400F583F3 /* RKISO8601DateFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 25CDA0DB161E7ED400F583F3 /* RKISO8601DateFormatter.m */; };
|
||||
25CDA0DF161E7ED400F583F3 /* RKISO8601DateFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 25CDA0DB161E7ED400F583F3 /* RKISO8601DateFormatter.m */; };
|
||||
25CDA0E7161E828D00F583F3 /* RKISODateFormatterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25CDA0E2161E821000F583F3 /* RKISODateFormatterTest.m */; };
|
||||
25CDA0E8161E828E00F583F3 /* RKISODateFormatterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25CDA0E2161E821000F583F3 /* RKISODateFormatterTest.m */; };
|
||||
25DB7508151BD551009F01AF /* NSManagedObjectContext+RKAdditionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DB7507151BD551009F01AF /* NSManagedObjectContext+RKAdditionsTest.m */; };
|
||||
25DB7509151BD551009F01AF /* NSManagedObjectContext+RKAdditionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DB7507151BD551009F01AF /* NSManagedObjectContext+RKAdditionsTest.m */; };
|
||||
25E36E0215195CED00F9E448 /* RKFetchRequestMappingCacheTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 25E36E0115195CED00F9E448 /* RKFetchRequestMappingCacheTest.m */; };
|
||||
@@ -535,10 +541,6 @@
|
||||
25FBB854159272DD00955D27 /* RKRouter.m in Sources */ = {isa = PBXBuildFile; fileRef = 25FBB851159272DD00955D27 /* RKRouter.m */; };
|
||||
25FBB855159272DD00955D27 /* RKRouter.m in Sources */ = {isa = PBXBuildFile; fileRef = 25FBB851159272DD00955D27 /* RKRouter.m */; };
|
||||
36F3D0E4FD7C4C4AA2B4FEB2 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C8C87FF6727A42D68CA2220E /* libPods.a */; };
|
||||
49D2759D14C9EF1E0090845D /* ISO8601DateFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 49D2759914C9EF1E0090845D /* ISO8601DateFormatter.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
49D2759E14C9EF1E0090845D /* ISO8601DateFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 49D2759914C9EF1E0090845D /* ISO8601DateFormatter.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
49D2759F14C9EF1E0090845D /* ISO8601DateFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 49D2759A14C9EF1E0090845D /* ISO8601DateFormatter.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
49D275A114C9EF1E0090845D /* ISO8601DateFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 49D2759A14C9EF1E0090845D /* ISO8601DateFormatter.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
5C927E141608FFFD00DC8B07 /* RKDictionaryUtilitiesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C927E131608FFFD00DC8B07 /* RKDictionaryUtilitiesTest.m */; };
|
||||
5C927E151608FFFD00DC8B07 /* RKDictionaryUtilitiesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C927E131608FFFD00DC8B07 /* RKDictionaryUtilitiesTest.m */; };
|
||||
5CCC295615B7124A0045F0F5 /* RKMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CCC295515B7124A0045F0F5 /* RKMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@@ -874,6 +876,9 @@
|
||||
25CA7A8E14EC570100888FF8 /* RKMapping.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKMapping.m; sourceTree = "<group>"; };
|
||||
25CAAA9315254E7800CAE5D7 /* ArrayOfHumans.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = ArrayOfHumans.json; sourceTree = "<group>"; };
|
||||
25CC5C58161DDADD0008BD21 /* RKResponseDescriptorTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKResponseDescriptorTest.m; sourceTree = "<group>"; };
|
||||
25CDA0DA161E7ED400F583F3 /* RKISO8601DateFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKISO8601DateFormatter.h; sourceTree = "<group>"; };
|
||||
25CDA0DB161E7ED400F583F3 /* RKISO8601DateFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKISO8601DateFormatter.m; sourceTree = "<group>"; };
|
||||
25CDA0E2161E821000F583F3 /* RKISODateFormatterTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKISODateFormatterTest.m; sourceTree = "<group>"; };
|
||||
25DB7507151BD551009F01AF /* NSManagedObjectContext+RKAdditionsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObjectContext+RKAdditionsTest.m"; sourceTree = "<group>"; };
|
||||
25E36E0115195CED00F9E448 /* RKFetchRequestMappingCacheTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKFetchRequestMappingCacheTest.m; sourceTree = "<group>"; };
|
||||
25EC1AD814F8022600C3CF3F /* RestKitFramework-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "RestKitFramework-Info.plist"; sourceTree = "<group>"; };
|
||||
@@ -888,10 +893,6 @@
|
||||
25FBB850159272DD00955D27 /* RKRouter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKRouter.h; sourceTree = "<group>"; };
|
||||
25FBB851159272DD00955D27 /* RKRouter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKRouter.m; sourceTree = "<group>"; };
|
||||
41A4EBF715374D1800740BC8 /* redirection.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = redirection.rb; sourceTree = "<group>"; };
|
||||
49D2759914C9EF1E0090845D /* ISO8601DateFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ISO8601DateFormatter.h; path = iso8601parser/ISO8601DateFormatter.h; sourceTree = "<group>"; };
|
||||
49D2759A14C9EF1E0090845D /* ISO8601DateFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ISO8601DateFormatter.m; path = iso8601parser/ISO8601DateFormatter.m; sourceTree = "<group>"; };
|
||||
49D2759B14C9EF1E0090845D /* LICENSE.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE.txt; path = iso8601parser/LICENSE.txt; sourceTree = "<group>"; };
|
||||
49D2759C14C9EF1E0090845D /* README.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = README.txt; path = iso8601parser/README.txt; sourceTree = "<group>"; };
|
||||
5C927E131608FFFD00DC8B07 /* RKDictionaryUtilitiesTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKDictionaryUtilitiesTest.m; sourceTree = "<group>"; };
|
||||
5CCC295515B7124A0045F0F5 /* RKMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKMacros.h; sourceTree = "<group>"; };
|
||||
7394DF3514CF157A00CE7BCE /* RKManagedObjectCaching.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKManagedObjectCaching.h; sourceTree = "<group>"; };
|
||||
@@ -1170,6 +1171,8 @@
|
||||
5CCC295515B7124A0045F0F5 /* RKMacros.h */,
|
||||
253477EF15FFBC60002C0E4E /* RKDictionaryUtilities.h */,
|
||||
253477F015FFBC60002C0E4E /* RKDictionaryUtilities.m */,
|
||||
25CDA0DA161E7ED400F583F3 /* RKISO8601DateFormatter.h */,
|
||||
25CDA0DB161E7ED400F583F3 /* RKISO8601DateFormatter.m */,
|
||||
);
|
||||
path = Support;
|
||||
sourceTree = "<group>";
|
||||
@@ -1188,7 +1191,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
25BCB31715ED57D500EE84DD /* AFNetworking */,
|
||||
49D2759714C9E83E0090845D /* iso8601parser */,
|
||||
25160EA01456532C0060A5C5 /* LibComponentLogging */,
|
||||
25160EB71456532C0060A5C5 /* SOCKit */,
|
||||
);
|
||||
@@ -1478,6 +1480,7 @@
|
||||
251610541456F2330060A5C5 /* RKDotNetDateFormatterTest.m */,
|
||||
251610561456F2330060A5C5 /* RKPathMatcherTest.m */,
|
||||
2501405215366000004E0466 /* RKObjectiveCppTest.mm */,
|
||||
25CDA0E2161E821000F583F3 /* RKISODateFormatterTest.m */,
|
||||
);
|
||||
name = Support;
|
||||
path = Logic/Support;
|
||||
@@ -1552,17 +1555,6 @@
|
||||
path = PLISTs;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
49D2759714C9E83E0090845D /* iso8601parser */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
49D2759914C9EF1E0090845D /* ISO8601DateFormatter.h */,
|
||||
49D2759A14C9EF1E0090845D /* ISO8601DateFormatter.m */,
|
||||
49D2759B14C9EF1E0090845D /* LICENSE.txt */,
|
||||
49D2759C14C9EF1E0090845D /* README.txt */,
|
||||
);
|
||||
name = iso8601parser;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E4081DFC15FB89DF00364948 /* ManagedObjectCaching */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -1678,7 +1670,6 @@
|
||||
25160F081456532C0060A5C5 /* SOCKit.h in Headers */,
|
||||
25160E2E145650490060A5C5 /* RestKit.h in Headers */,
|
||||
25B408261491CDDC00F21111 /* RKPathUtilities.h in Headers */,
|
||||
49D2759D14C9EF1E0090845D /* ISO8601DateFormatter.h in Headers */,
|
||||
25B6E95514CF795D00B1E881 /* RKErrors.h in Headers */,
|
||||
25B6E95C14CF7E3C00B1E881 /* RKDynamicMappingMatcher.h in Headers */,
|
||||
253B495214E35D1A00B0483F /* RKTestFixture.h in Headers */,
|
||||
@@ -1745,6 +1736,7 @@
|
||||
25F53F391606269400A093BE /* RKRequestOperationSubclass.h in Headers */,
|
||||
25A226D61618A57500952D72 /* RKObjectUtilities.h in Headers */,
|
||||
2507C327161BD5C700EA71FF /* RKTestHelpers.h in Headers */,
|
||||
25CDA0DC161E7ED400F583F3 /* RKISO8601DateFormatter.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -1781,7 +1773,6 @@
|
||||
25160F981456576C0060A5C5 /* RKPathMatcher.h in Headers */,
|
||||
25160F25145655AF0060A5C5 /* RestKit.h in Headers */,
|
||||
25B408271491CDDC00F21111 /* RKPathUtilities.h in Headers */,
|
||||
49D2759E14C9EF1E0090845D /* ISO8601DateFormatter.h in Headers */,
|
||||
25B6E95614CF795D00B1E881 /* RKErrors.h in Headers */,
|
||||
25B6E95D14CF7E3C00B1E881 /* RKDynamicMappingMatcher.h in Headers */,
|
||||
25FABED314E3796C00E609E7 /* RKTestNotificationObserver.h in Headers */,
|
||||
@@ -1846,6 +1837,7 @@
|
||||
25F53F3A1606269400A093BE /* RKRequestOperationSubclass.h in Headers */,
|
||||
25A226D71618A57500952D72 /* RKObjectUtilities.h in Headers */,
|
||||
2507C328161BD5C700EA71FF /* RKTestHelpers.h in Headers */,
|
||||
25CDA0DD161E7ED400F583F3 /* RKISO8601DateFormatter.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -2145,7 +2137,6 @@
|
||||
25160EFA1456532C0060A5C5 /* LCLNSLog_RK.m in Sources */,
|
||||
25160F0A1456532C0060A5C5 /* SOCKit.m in Sources */,
|
||||
25B408281491CDDC00F21111 /* RKPathUtilities.m in Sources */,
|
||||
49D2759F14C9EF1E0090845D /* ISO8601DateFormatter.m in Sources */,
|
||||
25B6E95814CF7A1C00B1E881 /* RKErrors.m in Sources */,
|
||||
25B6E95E14CF7E3C00B1E881 /* RKDynamicMappingMatcher.m in Sources */,
|
||||
25FABED114E3796400E609E7 /* RKTestNotificationObserver.m in Sources */,
|
||||
@@ -2201,6 +2192,7 @@
|
||||
259B96F31604CCCC0000C250 /* UIImageView+AFNetworking.m in Sources */,
|
||||
25A226D81618A57500952D72 /* RKObjectUtilities.m in Sources */,
|
||||
2507C329161BD5C700EA71FF /* RKTestHelpers.m in Sources */,
|
||||
25CDA0DE161E7ED400F583F3 /* RKISO8601DateFormatter.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -2255,6 +2247,7 @@
|
||||
25EDFCE3161538F6008BAA1D /* RKObjectManagerTest.m in Sources */,
|
||||
2564E40B16173F7B00C12D7D /* RKRelationshipConnectionOperationTest.m in Sources */,
|
||||
25CC5C59161DDADD0008BD21 /* RKResponseDescriptorTest.m in Sources */,
|
||||
25CDA0E7161E828D00F583F3 /* RKISODateFormatterTest.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -2285,7 +2278,6 @@
|
||||
25160F961456576C0060A5C5 /* RKMIMETypes.m in Sources */,
|
||||
25160F991456576C0060A5C5 /* RKPathMatcher.m in Sources */,
|
||||
25B408291491CDDC00F21111 /* RKPathUtilities.m in Sources */,
|
||||
49D275A114C9EF1E0090845D /* ISO8601DateFormatter.m in Sources */,
|
||||
25B6E95914CF7A1C00B1E881 /* RKErrors.m in Sources */,
|
||||
25B6E95F14CF7E3C00B1E881 /* RKDynamicMappingMatcher.m in Sources */,
|
||||
25FABED014E3796400E609E7 /* RKTestNotificationObserver.m in Sources */,
|
||||
@@ -2341,6 +2333,7 @@
|
||||
25E9C8F1161290D500647F84 /* RKObjectParameterization.m in Sources */,
|
||||
25A226D91618A57500952D72 /* RKObjectUtilities.m in Sources */,
|
||||
2507C32A161BD5C700EA71FF /* RKTestHelpers.m in Sources */,
|
||||
25CDA0DF161E7ED400F583F3 /* RKISO8601DateFormatter.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -2395,6 +2388,7 @@
|
||||
25EDFCE5161538F8008BAA1D /* RKObjectManagerTest.m in Sources */,
|
||||
2564E40C16173F7B00C12D7D /* RKRelationshipConnectionOperationTest.m in Sources */,
|
||||
25CC5C5A161DDADD0008BD21 /* RKResponseDescriptorTest.m in Sources */,
|
||||
25CDA0E8161E828E00F583F3 /* RKISODateFormatterTest.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
35
Tests/Logic/Support/RKISODateFormatterTest.m
Normal file
35
Tests/Logic/Support/RKISODateFormatterTest.m
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// RKISODateFormatterTest.m
|
||||
// RestKit
|
||||
//
|
||||
// Created by Blake Watters on 10/4/12.
|
||||
// Copyright (c) 2012 RestKit. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RKTestEnvironment.h"
|
||||
#import "RKISO8601DateFormatter.h"
|
||||
|
||||
@interface RKISODateFormatterTest : RKTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation RKISODateFormatterTest
|
||||
|
||||
- (void)testDateFormatterRespectsTimeZone
|
||||
{
|
||||
RKISO8601DateFormatter *formatter = [[RKISO8601DateFormatter alloc] init];
|
||||
[formatter setIncludeTime:YES];
|
||||
[formatter setDefaultTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]]; // UTC
|
||||
|
||||
NSDateFormatter *nsformatter = [[NSDateFormatter alloc] init];
|
||||
[nsformatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
|
||||
[nsformatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]]; // UTC
|
||||
|
||||
NSDate *date = [NSDate date];
|
||||
NSString *isoFormatted = [formatter stringFromDate:date];
|
||||
NSString *nsFormatted = [nsformatter stringFromDate:date];
|
||||
|
||||
expect(isoFormatted).to.equal(nsFormatted);
|
||||
}
|
||||
|
||||
@end
|
||||
9
Vendor/iso8601parser/LICENSE.txt
vendored
9
Vendor/iso8601parser/LICENSE.txt
vendored
@@ -1,9 +0,0 @@
|
||||
Copyright © 2006–2011 Peter Hosey
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
Neither the name of Peter Hosey nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
126
Vendor/iso8601parser/README.txt
vendored
126
Vendor/iso8601parser/README.txt
vendored
@@ -1,126 +0,0 @@
|
||||
How to use in your program
|
||||
==========================
|
||||
|
||||
Add the source files to your project.
|
||||
|
||||
Parsing
|
||||
-------
|
||||
|
||||
Create an ISO 8601 date formatter, then call [formatter dateFromString:myString]. The method will return either an NSDate or nil.
|
||||
|
||||
There are a total of six parser methods. The one that contains the actual parser is -[ISO8601DateFormatter dateComponentsFromString:timeZone:range:]. The other five are based on this one.
|
||||
|
||||
The "outTimeZone" parameter, when not set to NULL, is a pointer to an NSTimeZone *variable. If the string specified a time zone, you'll receive the time zone object in that variable. If the string didn't specify a time zone, you'll receive nil.
|
||||
|
||||
The "outRange" parameter, when not set to NULL, is a pointer to NSRange storage. You will receive the range of the parsed substring in that storage.
|
||||
|
||||
Unparsing
|
||||
---------
|
||||
|
||||
Create an ISO 8601 date formatter, then call [formatter stringFromDate:myDate]. The method will return a string.
|
||||
|
||||
The formatter has several properties that control its behavior:
|
||||
|
||||
* You can set the format of the resulting strings. By default, the formatter will generate calendar-date strings; your other options are week dates and ordinal dates.
|
||||
* You can set a default time zone; by default, it will use [NSTimeZone defaultTimeZone].
|
||||
* You can enable a strict mode, wherein the formatter enforces sanity checks on the string. By default, the parser will afford you quite a bit of leeway.
|
||||
* You can set whether to include the time in the string, and if so, what hour-minute separator to use (default ':').
|
||||
|
||||
How to test that this code works
|
||||
================================
|
||||
|
||||
'make test' will perform all tests. If you want to perform only *some* tests:
|
||||
|
||||
Parsing
|
||||
-------
|
||||
|
||||
Type 'make parser-test'. make will build the test program (testparser), then invoke testparser.sh.py to generate testparser.sh. Then make will invoke testparser.sh, which will invoke the test program with various dates.
|
||||
|
||||
If you don't want to use my tests, 'make testparser' will create the test program without running it. You can then invoke testparser yourself with any date you want to. If it doesn't give you the result you expected, contact me, making sure to provide me with both the input and the output.
|
||||
|
||||
Unparsing
|
||||
---------
|
||||
|
||||
Type 'make unparser-test'. make will build the test programs, then invoke testunparser.sh. This shell script invokes each test program for -01-01 of every year from 1991 to 2010, writing the output to a file, and then runs diff -qs between that file (testunparser.out) and a file (testunparser-expected.out) containing known correct output. diff should report that the files are identical.
|
||||
|
||||
Three test programs are included: unparse-date, unparse-weekdate, and unparse-ordinal date. If you don't want to use my tests, you can make these test programs separately. Each takes a date specified by ISO 8601 (parsed with my own ISO 8601 parser), and outputs a string that should represent the same date.
|
||||
|
||||
Notes
|
||||
=====
|
||||
|
||||
Version history
|
||||
---------------
|
||||
|
||||
This version is 0.6. Changes from 0.5:
|
||||
* When not set to strict parsing, allow a space before the time-zone specification, for greater compatibility with NSDate output (`description`) and input (`dateWithString:`). 27603efc8a77
|
||||
* Bug fix: We no longer try to format the formatter. 83415de9f527
|
||||
* Bug fix: Hours are now zero-padded correctly ([#4](https://bitbucket.org/boredzo/iso-8601-parser-unparser/issue/4/time-zones-are-emitted-without-leading)). a5608e189ebe af0c6b397428
|
||||
* Fixed many various compiler warnings. Some fixes contributed by Sparks. 8be3d6f7c6f2 78ae31de2170 68dc351e9fdb e7ea87db8621 873f499ae6db
|
||||
* Now 75 times faster. 6a023812bd2b 05dc35d6b505 3b2225e0ce8c d59720ad015a 10f526956963 297b8dae4095 796be11aa596 cadf0f0c8199 61d2959c6921
|
||||
* iOS users can now tell the ISO 8601 date formatter class to drop its caches (which you should do when you receive a memory warning). 2bb1725914b1
|
||||
* Added a couple of command-line options to the calendar-format-unparser test tool. c644aadb2b14
|
||||
* The parser test tool now displays parsed dates in GMT rather than the local time zone. 788c1455ecb1
|
||||
* Added a test tool to test unparsing with the time included. a89a9a8b3d61
|
||||
* You can now “make analysis” to run the Clang Static Analyzer on the date formatter. b3dd33841f42
|
||||
* The test tools are now built using Clang. 0723d3aa6596
|
||||
|
||||
Changes in 0.5 from 0.4:
|
||||
* Rewrote as an NSFormatter subclass using NSCalendar.
|
||||
* Making it a formatter makes it much easier to use with Bindings.
|
||||
* Using NSCalendar means we're no longer using NSCalendarDate, which Apple has said they will deprecate at some point.
|
||||
* Fixed a bug in week date generation: One subtraction could give a negative result, which was a problem because my implementation of the algorithm used unsigned integers. I've changed it to use signed integers, so the result truly is negative now. I also added a test case for this.
|
||||
|
||||
Changes in 0.4 from 0.3:
|
||||
* Added the ability to use a time separator other than ':'.
|
||||
|
||||
Changes in 0.3 from 0.2:
|
||||
* Colin Barrett noticed that I used %m instead of %M when creating the time strings. Oops.
|
||||
* Colin also noticed that I had the ?: in -ISO8601DateStringWithTime: the wrong way around. Oops again.
|
||||
|
||||
Changes in 0.2 from 0.1:
|
||||
* The unparser is new. The has been munged to allow both components together,
|
||||
* The parser has not changed.
|
||||
|
||||
Parsing
|
||||
-------
|
||||
|
||||
Whitespace before a date, and anything after a date, is ignored. Thus, " T23 and all's well" is a valid date for the purpose of this method. (Yes, T23 is a valid ISO 8601 date. It means 23:00:00, or 11 PM.)
|
||||
|
||||
All of the frills of ISO 8601 are supported, except for extended dates (years longer than 4 digits). Specifically, you can use week-based dates (2006-W2 for the second week of 2006), ordinal dates (2006-365 for December 31), decimal minutes (11:30.5 == 11:30:30), and decimal seconds (11:30:10.5). All methods of specifying a time zone are supported.
|
||||
|
||||
ISO 8601 leaves quite a bit up to the parties exchanging dates. I hope I've chosen reasonable defaults. For example (note that I'm writing this on 2006-02-24):
|
||||
|
||||
• If the month or month and date are missing, 1 is assumed. "2006" == "2006-01-01".
|
||||
• If the year or year and month are missing, the current ones are assumed. "--02-01" == "2006-02-01". "---28" == "2006-02-28".
|
||||
• In the case of week-based dates, with the day missing, this implementation returns the first day of that week: 2006-W1 is 2006-01-01, 2006-W2 is 2006-01-08, etc.
|
||||
• For any date without a time, midnight on that date is used.
|
||||
• ISO 8601 permits the choice of either T0 or T24 for midnight. This implementation uses T0. T24 will get you T0 on the following day.
|
||||
• If no time-zone is specified, local time (as returned by [NSTimeZone localTimeZone]) is used.
|
||||
|
||||
When a date is parsed that has a year but no century, this implementation adds the current century.
|
||||
|
||||
The implementation is tolerant of out-of-range numbers. For example, "2005-13-40T24:62:89" == 1:02 AM on 2006-02-10. Notice that the month (13 > 12), date (40 > 31), hour (24 > 23), minute (62 > 59), and second (89 > 59) are all out-of-range.
|
||||
|
||||
As mentioned above, there is a "strict" mode that enforces sanity checks. In particular, the date must be the entire contents of the string, and numbers are range-checked. If you have any suggestions on how to make this mode more strict, contact me.
|
||||
|
||||
Unparsing
|
||||
---------
|
||||
|
||||
I use Rick McCarty's algorithm for converting calendar dates to week dates (http://personal.ecu.edu/mccartyr/ISOwdAlg.txt), slightly tweaked.
|
||||
|
||||
Bugs
|
||||
====
|
||||
|
||||
Parsing
|
||||
-------
|
||||
|
||||
* This method won't extract a date from just anywhere in a string, only immediately after the start of the string (or any leading whitespace). There are two solutions: either require you to invoke the parser on a string that is only an ISO 8601 date, with nothing before or after (bad for parsing purposes), or make the parser able to find an ISO 8601 date as a substring. I won't do the first one, and barring a patch, I probably won't do the second one either.
|
||||
|
||||
* Date ranges (also specified by ISO 8601) are not supported; this method will only return one date. To handle ranges would require at least one more method.
|
||||
|
||||
* There is no method to analyze a date string and tell you what was found in it (year, month, week, day, ordinal day, etc.). Feel free to submit a patch.
|
||||
|
||||
Copyright
|
||||
=========
|
||||
|
||||
This code is copyright 2006–2011 Peter Hosey. It is under the BSD license; see LICENSE.txt for the full text of the license.
|
||||
Reference in New Issue
Block a user