Set date to 12:00 hours.
This commit is contained in:
1 file changed
+14
-2
+14
-2
@@ -17,6 +17,7 @@
|
|||||||
static NSDictionary<NSString *, NSNumber *> *_defaultTypes;
|
static NSDictionary<NSString *, NSNumber *> *_defaultTypes;
|
||||||
static NSDateFormatter *_formatter;
|
static NSDateFormatter *_formatter;
|
||||||
static NSDateFormatter *_partialFormatter;
|
static NSDateFormatter *_partialFormatter;
|
||||||
|
static NSCalendar *_calendar;
|
||||||
|
|
||||||
+ (void)initialize
|
+ (void)initialize
|
||||||
{
|
{
|
||||||
@@ -52,14 +53,20 @@ static NSDateFormatter *_partialFormatter;
|
|||||||
MP42MetadataKeyShowWorkAndMovement: @(MP42MetadataItemDataTypeBool)};
|
MP42MetadataKeyShowWorkAndMovement: @(MP42MetadataItemDataTypeBool)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSTimeZone *gmt = [NSTimeZone timeZoneForSecondsFromGMT:0];
|
||||||
|
|
||||||
_formatter = [[NSDateFormatter alloc] init];
|
_formatter = [[NSDateFormatter alloc] init];
|
||||||
_formatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
|
_formatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
|
||||||
_formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ssZZZZZ";
|
_formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ssZZZZZ";
|
||||||
_formatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
|
_formatter.timeZone = gmt;
|
||||||
|
|
||||||
_partialFormatter = [[NSDateFormatter alloc] init];
|
_partialFormatter = [[NSDateFormatter alloc] init];
|
||||||
_partialFormatter.dateFormat = @"yyyy-MM-dd";
|
_partialFormatter.dateFormat = @"yyyy-MM-dd";
|
||||||
_partialFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
|
_partialFormatter.timeZone = gmt;
|
||||||
|
|
||||||
|
_calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
|
||||||
|
_calendar.timeZone = gmt;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithIdentifier:(NSString *)identifier
|
- (instancetype)initWithIdentifier:(NSString *)identifier
|
||||||
@@ -128,6 +135,11 @@ static NSDateFormatter *_partialFormatter;
|
|||||||
_value = [_formatter dateFromString:stringValue];
|
_value = [_formatter dateFromString:stringValue];
|
||||||
if (!_value) {
|
if (!_value) {
|
||||||
_value = [_partialFormatter dateFromString:stringValue];
|
_value = [_partialFormatter dateFromString:stringValue];
|
||||||
|
if (_value) {
|
||||||
|
NSDateComponents *components = [_calendar components:NSUIntegerMax fromDate:(NSDate *)_value];
|
||||||
|
components.hour = 12;
|
||||||
|
_value = [_calendar dateFromComponents:components];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!_value) {
|
if (!_value) {
|
||||||
_value = stringValue;
|
_value = stringValue;
|
||||||
|
|||||||
Reference in new issue
Block a user