Skip to content

Commit e34119d

Browse files
author
Shan Ul Haq
committed
fixed date parsing in SHRealmObject
1 parent 32e6abb commit e34119d

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

SHModelObject/SHModelObject/SHRealmObject.m

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ + (instancetype)objectWithDictionary:(NSDictionary *)dictionary
110110
if (nil == dictionary || ![dictionary isKindOfClass:[NSDictionary class]]) {
111111
return nil;
112112
}
113-
113+
114114
if ([dictionary isKindOfClass:[NSNull class]]) {
115115
return nil;
116116
}
@@ -127,7 +127,7 @@ + (instancetype)objectWithDictionary:(NSDictionary *)dictionary
127127
if (nil == dictionary || ![dictionary isKindOfClass:[NSDictionary class]]) {
128128
return nil;
129129
}
130-
130+
131131
if ([dictionary isKindOfClass:[NSNull class]]) {
132132
return nil;
133133
}
@@ -137,7 +137,6 @@ + (instancetype)objectWithDictionary:(NSDictionary *)dictionary
137137
mappings:mapping];
138138
}
139139

140-
141140
//
142141
- (instancetype)initWithDictionary:(NSDictionary *)dictionary;
143142
{
@@ -190,7 +189,6 @@ - (instancetype)initWithDictionary:(NSDictionary *)dictionary
190189
return self;
191190
}
192191

193-
194192
// NSCoding
195193
- (NSArray *)propertyNames {
196194
NSMutableArray *array = [NSMutableArray array];
@@ -290,7 +288,7 @@ - (instancetype)updateWithDictionary:(NSDictionary *)dictionary
290288
[_customFormatter setDateFormat:_customInputDateFormatString];
291289
}
292290
_mappings = mapping;
293-
291+
294292
return [self updateWithDictionary:dictionary];
295293
}
296294

@@ -302,7 +300,7 @@ - (instancetype)updateWithDictionary:(NSDictionary *)dictionary
302300
_inputDateFormat = kInputDateFormatCustom;
303301
_customFormatter = inputDateFormatter;
304302
_mappings = mapping;
305-
303+
306304
return [self updateWithDictionary:dictionary];
307305
}
308306

@@ -351,6 +349,10 @@ - (void)serializeValue:(id)value withKey:(id)key {
351349
case kInputDateFormatDotNetWithTimeZone: {
352350
value = (NSDate *)[_timezoneDateFormatter dateFromString:value];
353351
} break;
352+
case kInputDateFormatCustom: {
353+
value = (NSDate *)[_customFormatter dateFromString:value];
354+
} break;
355+
354356
default: { value = (NSDate *)[self dateFromDotNetJSONString:value]; } break;
355357
}
356358
}
@@ -367,6 +369,9 @@ - (void)serializeValue:(id)value withKey:(id)key {
367369
case kInputDateFormatDotNetWithTimeZone: {
368370
value = @([[_timezoneDateFormatter dateFromString:value] timeIntervalSince1970]);
369371
} break;
372+
case kInputDateFormatCustom: {
373+
value = @([[_customFormatter dateFromString:value] timeIntervalSince1970]);
374+
} break;
370375
default: {
371376
value = @([[self dateFromDotNetJSONString:value] timeIntervalSince1970]);
372377
} break;

0 commit comments

Comments
 (0)