Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SF iOS/SF iOS/Helpers/NSDateUtilities/NSDate+Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ NS_ASSUME_NONNULL_BEGIN

- (NSString *)stringWithformat:(NSString *)format;

+ (NSISO8601DateFormatter *)formatter;

- (NSString *)weekdayName;

- (BOOL)isLaterThanDate:(NSDate *)date;
Expand Down
12 changes: 12 additions & 0 deletions SF iOS/SF iOS/Helpers/NSDateUtilities/NSDate+Utilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ - (NSString *)abbreviatedTimeintervalFromNow {
return [NSDate abbreviatedTimeIntervalForTimeInterval:difference];
}

+ (NSISO8601DateFormatter *)formatter {
NSISO8601DateFormatter *formatter = [[NSISO8601DateFormatter alloc] init];
[formatter setFormatOptions: NSISO8601DateFormatWithFullDate |
NSISO8601DateFormatWithFullTime |
NSISO8601DateFormatWithTimeZone |
NSISO8601DateFormatWithDashSeparatorInDate |
NSISO8601DateFormatWithColonSeparatorInTime |
NSISO8601DateFormatWithColonSeparatorInTimeZone |
NSISO8601DateFormatWithFractionalSeconds];
return formatter;
}

+ (NSString *)abbreviatedTimeIntervalForTimeInterval:(NSTimeInterval)timeInterval {
NSDateComponentsFormatter *formatter = [NSDateComponentsFormatter new];
formatter.unitsStyle = NSDateComponentsFormatterUnitsStyleAbbreviated;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ - (void)start {

__weak typeof(self) welf = self;
for (Group *group in groups) {
NSString *groupName = group.name;
dispatch_group_enter(dipatchGroup);
BackgroundFetcher *fetcher = [[BackgroundFetcher alloc] initForGroup:group withCompletionHandler:^(UIBackgroundFetchResult result) {
switch (result) {
Expand Down
3 changes: 2 additions & 1 deletion SF iOS/SF iOS/Location/FeedFetch/FeedFetchService.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#import "FeedFetchService.h"
#import "FeedFetchOperation.h"
#import "Event.h"
#import "NSDate+Utilities.h"

@interface FeedFetchService ()
@property (nonatomic) NSOperationQueue *feedFetchQueue;
Expand All @@ -31,7 +32,7 @@ -(void)getFeedWithHandler:(FeedFetchCompletionHandler)completionHandler {
NSError *_Nullable error) {
NSMutableArray<Event *> *events = [[NSMutableArray alloc] initWithCapacity:feed.count];
for (NSDictionary *dict in feed) {
[events addObject:[[Event alloc] initWithDictionary:dict]];
[events addObject:[[Event alloc] initWithDictionary:dict dateFormatter:[NSDate formatter]]];
}
completionHandler(events, error);
}];
Expand Down
2 changes: 1 addition & 1 deletion SF iOS/SF iOS/Models/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) NSString *venueName;
@property (nonatomic, readonly) Location *location;

- (instancetype)initWithDictionary:(NSDictionary *)record;
- (instancetype)initWithDictionary:(NSDictionary *)record dateFormatter:(NSISO8601DateFormatter *)formatter;

- (nullable NSURL *)imageFileURL;
- (nullable NSURL *)venueURL;
Expand Down
6 changes: 1 addition & 5 deletions SF iOS/SF iOS/Models/Event.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@

@implementation Event

- (instancetype)initWithDictionary:(NSDictionary *)record {
- (instancetype)initWithDictionary:(NSDictionary *)record dateFormatter:(NSISO8601DateFormatter *)formatter {
if (self = [super init]) {
self.eventID = record[@"id"];
self.groupID = record[@"group_id"];
self.type = 0;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"];
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[formatter setLocale:locale];
NSString *startAt = record[@"start_at"];
self.date = [formatter dateFromString:startAt];
self.endDate = [formatter dateFromString:record[@"end_at"]];
Expand Down
4 changes: 3 additions & 1 deletion SF iOS/SF iOSTests/EventDataSourceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import <XCTest/XCTest.h>
#import "EventDataSource.h"
#import "NSDate+Utilities.h"
#import "FeedProviderDelegate.h"
#import <Realm/Realm.h>
#import "Group.h"
Expand Down Expand Up @@ -43,8 +44,9 @@ - (void)setUp {

self.group = [[Group alloc] init];
self.group.groupID = @"28ef50f9-b909-4f03-9a69-a8218a8cbd99";
self.event = [[Event alloc] initWithDictionary:dict];

self.event = [[Event alloc] initWithDictionary:dict dateFormatter:[NSDate formatter]];
XCTAssertNotNil(self.event.date);
_fetchingExpectation = [self expectationWithDescription:@"Wait for events"];

self.realmConfiguration = [RLMRealmConfiguration defaultConfiguration];
Expand Down
4 changes: 3 additions & 1 deletion SF iOS/SF iOSTests/EventNotificationCopyTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#import <XCTest/XCTest.h>
#import "NSString+EventNotifications.h"
#import "Event.h"
#import "NSDate+Utilities.h"

@interface EventNotificationCopyTests : XCTestCase
@property (nonatomic) Event *event;

Expand All @@ -34,7 +36,7 @@ - (void)setUp {
@"venue": venue,
@"start_at": @"2019-04-03T15:30:00.000Z"
};
self.event = [[Event alloc] initWithDictionary:dict];
self.event = [[Event alloc] initWithDictionary:dict dateFormatter:[NSDate formatter]];
self.event.type = EventTypeSFCoffee;
self.event.date = [NSDate dateWithTimeIntervalSince1970:123456];
}
Expand Down
8 changes: 6 additions & 2 deletions SF iOS/SF iOSTests/EventTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#import <XCTest/XCTest.h>
#import "Event.h"
#import "Venue.h"
#import "NSDate+Utilities.h"

@interface EventTests : XCTestCase

@property (nonatomic) Event *event;
Expand All @@ -34,10 +36,12 @@ - (void)setUp {
@"venue": venue,
@"start_at": @"2019-04-03T15:30:00.000Z"
};
self.event = [[Event alloc] initWithDictionary:dict];
self.event = [[Event alloc] initWithDictionary:dict dateFormatter:[NSDate formatter]];
self.event.type = EventTypeSFCoffee;
self.event.date = [NSDate new];
self.secondEvent = [[Event alloc] initWithDictionary:dict];
self.event = [[Event alloc] initWithDictionary:dict dateFormatter:[NSDate formatter]];
self.secondEvent = [[Event alloc] initWithDictionary:dict dateFormatter:[NSDate formatter]];

self.secondEvent.type = EventTypeSFCoffee;
self.secondEvent.date = self.event.date;
}
Expand Down
3 changes: 2 additions & 1 deletion SF iOS/SF iOSTests/FeedItemTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import <XCTest/XCTest.h>
#import "Event.h"
#import "FeedItem.h"
#import "NSDate+Utilities.h"

@interface FeedItemTests : XCTestCase

Expand Down Expand Up @@ -38,7 +39,7 @@ - (void)setUp {
@"venue": venue,
@"start_at": @"2019-04-03T15:30:00.000Z"
};
self.event = [[Event alloc] initWithDictionary:dict];
self.event = [[Event alloc] initWithDictionary:dict dateFormatter:[NSDate formatter]];
self.event.type = EventTypeSFCoffee;
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
self.noon = [calendar dateBySettingHour:12 minute:0 second:0 ofDate:[NSDate date] options:0];
Expand Down
3 changes: 2 additions & 1 deletion SF iOS/SF iOSTests/UNNotificationContentTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#import <XCTest/XCTest.h>
#import "UNNotificationContent+EventNotifications.h"
#import "Event.h"
#import "NSDate+Utilities.h"

@interface UNNotificationContentTests : XCTestCase
@property (nonatomic) Event *event;
Expand Down Expand Up @@ -35,7 +36,7 @@ - (void)setUp {
@"venue": venue,
@"start_at": @"2019-04-03T15:30:00.000Z"
};
self.event = [[Event alloc] initWithDictionary:dict];
self.event = [[Event alloc] initWithDictionary:dict dateFormatter:[NSDate formatter]];
self.event.type = EventTypeSFCoffee;
self.event.date = [NSDate new];
}
Expand Down