Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix 'dateBySubtractingDays:' #6

Closed
wants to merge 3 commits into from

2 participants

@exalted

'dateByAddingDays:' message to self won't work, because it needs an NSUInteger whereas (dDays * -1) will result to a negative number.

Same is presumably true for 'dateBySubtractingHours:' and 'dateBySubtractingMinutes:' also, not tested though.

exalted added some commits
@exalted exalted Fix 'dateBySubtractingDays:'
'dateByAddingDays:' message to self won't work, because it needs an
NSUInteger whereas (dDays * -1) will result to a negative number.
0964622
@exalted exalted Fixed intervals rounding to down instead of up 9143705
@exalted exalted Revert "Fixed intervals rounding to down instead of up"
This reverts commit 914370563b687c5c80ef377412a21977b461a9e4.
fba6b51
@erica
Owner
@erica
Owner

Fixed, thanks!

@erica erica closed this
@exalted

@erica thanks! That's a huge time gap, after 2 years... ;-) I guess that would do it. Cheers,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 3, 2011
  1. @exalted

    Fix 'dateBySubtractingDays:'

    exalted authored
    'dateByAddingDays:' message to self won't work, because it needs an
    NSUInteger whereas (dDays * -1) will result to a negative number.
Commits on Oct 21, 2011
  1. @exalted
  2. @exalted

    Revert "Fixed intervals rounding to down instead of up"

    exalted authored
    This reverts commit 914370563b687c5c80ef377412a21977b461a9e4.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 NSDate-Utilities.m
View
4 NSDate-Utilities.m
@@ -179,7 +179,9 @@ - (NSDate *) dateByAddingDays: (NSUInteger) dDays
- (NSDate *) dateBySubtractingDays: (NSUInteger) dDays
{
- return [self dateByAddingDays: (dDays * -1)];
+ NSTimeInterval aTimeInterval = [self timeIntervalSinceReferenceDate] - D_DAY * dDays;
+ NSDate *newDate = [NSDate dateWithTimeIntervalSinceReferenceDate:aTimeInterval];
+ return newDate;
}
- (NSDate *) dateByAddingHours: (NSUInteger) dHours
Something went wrong with that request. Please try again.