Skip to content

Commit

Permalink
Fixed intervals rounding to down instead of up
Browse files Browse the repository at this point in the history
  • Loading branch information
exalted committed Oct 21, 2011
1 parent 0964622 commit 9143705
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions NSDate-Utilities.m
Expand Up @@ -228,37 +228,37 @@ - (NSDateComponents *) componentsWithOffsetFromDate: (NSDate *) aDate
- (NSInteger) minutesAfterDate: (NSDate *) aDate
{
NSTimeInterval ti = [self timeIntervalSinceDate:aDate];
return (NSInteger) (ti / D_MINUTE);
return (NSInteger) ceil (ti / D_MINUTE);
}

- (NSInteger) minutesBeforeDate: (NSDate *) aDate
{
NSTimeInterval ti = [aDate timeIntervalSinceDate:self];
return (NSInteger) (ti / D_MINUTE);
return (NSInteger) ceil (ti / D_MINUTE);
}

- (NSInteger) hoursAfterDate: (NSDate *) aDate
{
NSTimeInterval ti = [self timeIntervalSinceDate:aDate];
return (NSInteger) (ti / D_HOUR);
return (NSInteger) ceil (ti / D_HOUR);
}

- (NSInteger) hoursBeforeDate: (NSDate *) aDate
{
NSTimeInterval ti = [aDate timeIntervalSinceDate:self];
return (NSInteger) (ti / D_HOUR);
return (NSInteger) ceil (ti / D_HOUR);
}

- (NSInteger) daysAfterDate: (NSDate *) aDate
{
NSTimeInterval ti = [self timeIntervalSinceDate:aDate];
return (NSInteger) (ti / D_DAY);
return (NSInteger) ceil (ti / D_DAY);
}

- (NSInteger) daysBeforeDate: (NSDate *) aDate
{
NSTimeInterval ti = [aDate timeIntervalSinceDate:self];
return (NSInteger) (ti / D_DAY);
return (NSInteger) ceil (ti / D_DAY);
}

#pragma mark Decomposing Dates
Expand Down

0 comments on commit 9143705

Please sign in to comment.