Skip to content

Commit

Permalink
Fix what looks like a daylight savings time issue with date comparisons.
Browse files Browse the repository at this point in the history
When comparing the dates of the filename to the loaded date.  When the
date was saved to the data file it seems to have included a time of
1am.  The date was subsequently compared to ldate which had a time of
12am so some files were not loaded properly.
  • Loading branch information
haslup committed Dec 17, 2009
1 parent 3c79aca commit 2f222fc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Classes/ReportManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ - (id)init
}

NSArray *filenames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:docPath error:NULL];

NSCalendar *calendar = [NSCalendar currentCalendar];

for (NSString *filename in filenames) {
if (![[filename pathExtension] isEqual:@"dat"])
Expand All @@ -53,11 +55,13 @@ - (id)init
{
if (loadedDay.date)
{
NSDateComponents *components = [calendar components:(NSWeekdayCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:loadedDay.date];
NSDate *loadedDate = [calendar dateFromComponents:components];
NSDateFormatter * lFormat = [NSDateFormatter new];
[lFormat setDateFormat:@"MM/dd/yyyy"];
NSDate *lDate = [lFormat dateFromString:[loadedDay name]];
[lFormat release];
if ([lDate isEqual:loadedDay.date])
if ([lDate isEqual:loadedDate])
[self.days setObject:loadedDay forKey:[loadedDay name]];
}
}
Expand Down

0 comments on commit 2f222fc

Please sign in to comment.