ability to use dateFormat.1 and so on as a failover

This commit is contained in:
StuFF mc
2013-01-24 00:17:13 +01:00
parent be65087d8b
commit d3fc9fc84b

View File

@@ -36,8 +36,19 @@
{
if (![value isKindOfClass:[NSDate class]])
{
NSString *dateFormat = [[self userInfo] valueForKey:kMagicalRecordImportCustomDateFormatKey];
value = dateFromString([value description], dateFormat ?: kMagicalRecordImportDefaultDateFormatString);
NSDate *convertedValue = nil;
NSString *dateFormat;
NSUInteger index = 0;
do {
NSMutableString *dateFormatKey = [kMagicalRecordImportCustomDateFormatKey mutableCopy];
if (index) {
[dateFormatKey appendFormat:@".%d", index];
}
index++;
dateFormat = [[self userInfo] valueForKey:dateFormatKey];
convertedValue = dateFromString([value description], dateFormat ?: kMagicalRecordImportDefaultDateFormatString);
} while (!convertedValue && dateFormat);
value = convertedValue;
}
// value = adjustDateForDST(value);
}