Skip to content

Commit

Permalink
Merge pull request #29 from akuraru/master
Browse files Browse the repository at this point in the history
isThisWeek return always returns YES on (previous) sunday
  • Loading branch information
akuraru committed May 31, 2015
2 parents 83c1ad0 + a881e11 commit 4efdd0d
Show file tree
Hide file tree
Showing 11 changed files with 606 additions and 393 deletions.
14 changes: 0 additions & 14 deletions NSDate-Escort.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
17B5C28A17FECDD022B846E6 /* NSDate+Escort.m in Sources */ = {isa = PBXBuildFile; fileRef = 17B5C5CD74BE7F1C57C3F0DB /* NSDate+Escort.m */; };
17B5C2B8A7A6075B69DA69E2 /* NSDate+AZDateBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = 17B5C8F1C4BE74C402F443AA /* NSDate+AZDateBuilder.m */; };
17B5C474F10F4D9620AFFACC /* FakeDateUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 17B5CF001E83A221023FE180 /* FakeDateUtil.m */; };
17B5C584E29A91E50FA691ED /* EscortComparingSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 17B5C809EA2391FF7D79ECD6 /* EscortComparingSpec.m */; };
17B5C81B2A6B6A58E9622A62 /* dateByAddingTimeIntervalTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 17B5C27D1F0600AF19D12738 /* dateByAddingTimeIntervalTests.m */; };
Expand Down Expand Up @@ -38,7 +37,6 @@
0C99433D664648BDA821D25A /* libPods-Test.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Test.a"; sourceTree = BUILT_PRODUCTS_DIR; };
17B5C01AAD723EBDDDCC62A1 /* EscortDateRoles.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EscortDateRoles.m; sourceTree = "<group>"; };
17B5C27D1F0600AF19D12738 /* dateByAddingTimeIntervalTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = dateByAddingTimeIntervalTests.m; sourceTree = "<group>"; };
17B5C2A41A6F8CEED07514BF /* NSDate+AZDateBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+AZDateBuilder.h"; sourceTree = "<group>"; };
17B5C2FFCAB36B1E0C17E2BF /* readme.md */ = {isa = PBXFileReference; lastKnownFileType = file.md; path = readme.md; sourceTree = "<group>"; };
17B5C3CB2F1D7F92A7D5D185 /* EscortRetrievingIntervalsSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EscortRetrievingIntervalsSpec.m; sourceTree = "<group>"; };
17B5C5CD74BE7F1C57C3F0DB /* NSDate+Escort.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = "NSDate+Escort.m"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
Expand All @@ -48,7 +46,6 @@
17B5C8039CF17DE12A52A9B3 /* NSDate+Escort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+Escort.h"; sourceTree = "<group>"; };
17B5C809EA2391FF7D79ECD6 /* EscortComparingSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EscortComparingSpec.m; sourceTree = "<group>"; };
17B5C834FD0E39402F12D7CD /* BenchMakeFormReferenceDate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BenchMakeFormReferenceDate.m; sourceTree = "<group>"; };
17B5C8F1C4BE74C402F443AA /* NSDate+AZDateBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = "NSDate+AZDateBuilder.m"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
17B5CA6E7413A743441E0EF2 /* EscortDecomposingSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EscortDecomposingSpec.m; sourceTree = "<group>"; };
17B5CC3FA3B3583B8AC95DD8 /* EscortCacheSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EscortCacheSpec.m; sourceTree = "<group>"; };
17B5CC93C309A75B3ABE30BE /* RAIIBenchmark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RAIIBenchmark.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -128,21 +125,11 @@
17B5CC2CE306C225BB3E62CC /* Lib */ = {
isa = PBXGroup;
children = (
17B5CC5DBA9E23449DC98E0D /* AZDateBuilder */,
17B5C141C52FB324DABC53BC /* FakeDateUtil */,
);
path = Lib;
sourceTree = "<group>";
};
17B5CC5DBA9E23449DC98E0D /* AZDateBuilder */ = {
isa = PBXGroup;
children = (
17B5C8F1C4BE74C402F443AA /* NSDate+AZDateBuilder.m */,
17B5C2A41A6F8CEED07514BF /* NSDate+AZDateBuilder.h */,
);
path = AZDateBuilder;
sourceTree = "<group>";
};
7342338E176498610036715A /* Benchmark */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -393,7 +380,6 @@
files = (
17B5C28A17FECDD022B846E6 /* NSDate+Escort.m in Sources */,
17B5C9F98AC409F47299D54B /* EscortDecomposingSpec.m in Sources */,
17B5C2B8A7A6075B69DA69E2 /* NSDate+AZDateBuilder.m in Sources */,
C5BD6A39196287E30053103A /* AZNLTQuickCheckKiwiMatcher.m in Sources */,
17B5C474F10F4D9620AFFACC /* FakeDateUtil.m in Sources */,
17B5C94FD65CD923332ED3EE /* EscortCacheSpec.m in Sources */,
Expand Down
7 changes: 5 additions & 2 deletions NSDate-Escort/NSDate+Escort.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ - (BOOL)isYesterday {
}

- (BOOL)isSameWeekAsDate:(NSDate *) aDate {
NSDate *left = [self dateBySubtractingDays:self.weekday];
NSDate *right = [aDate dateBySubtractingDays:aDate.weekday];
NSCalendar *currentCalendar = [NSDate AZ_currentCalendar];
NSInteger leftWeekday = self.weekday + ((self.weekday < currentCalendar.firstWeekday) ? 7 : 0);
NSDate *left = [self dateBySubtractingDays:leftWeekday];
NSInteger rightWeekday = aDate.weekday + ((aDate.weekday < currentCalendar.firstWeekday) ? 7 : 0);
NSDate *right = [aDate dateBySubtractingDays:rightWeekday];
return [left isEqualToDateIgnoringTime:right];
}

Expand Down
1 change: 1 addition & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ platform :ios, '6.0'
target :Test, :exclusive => true do
pod 'Kiwi'
pod 'NLTQuickCheck'
pod 'AZDateBuilder'
end
Loading

0 comments on commit 4efdd0d

Please sign in to comment.