mirror of
https://github.com/zhigang1992/MagicalRecord.git
synced 2026-01-12 17:32:18 +08:00
ability to use dateFormat.1 and so on as a failover
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user