Skip to content

Commit

Permalink
remove NSDate warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakey committed Dec 4, 2016
1 parent fb56bfb commit 0810ada
Show file tree
Hide file tree
Showing 8 changed files with 629 additions and 285 deletions.
6 changes: 0 additions & 6 deletions JKCategories-Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@
A2958CB41B35792300D7AA0F /* CAMediaTimingFunction+JKAdditionalEquations.m in Sources */ = {isa = PBXBuildFile; fileRef = A2958CB31B35792300D7AA0F /* CAMediaTimingFunction+JKAdditionalEquations.m */; };
A2958CB71B35794500D7AA0F /* UIView+JKVisuals.m in Sources */ = {isa = PBXBuildFile; fileRef = A2958CB61B35794500D7AA0F /* UIView+JKVisuals.m */; };
A2958CBA1B357AEF00D7AA0F /* UIViewController+JKStoreKit.m in Sources */ = {isa = PBXBuildFile; fileRef = A2958CB91B357AEF00D7AA0F /* UIViewController+JKStoreKit.m */; };
A2958CC11B357E2E00D7AA0F /* CAAnimation+Blocks.m in Sources */ = {isa = PBXBuildFile; fileRef = A2958CC01B357E2E00D7AA0F /* CAAnimation+Blocks.m */; };
A2958CC41B357E9100D7AA0F /* CAAnimation+JKEasingEquations.m in Sources */ = {isa = PBXBuildFile; fileRef = A2958CC31B357E9100D7AA0F /* CAAnimation+JKEasingEquations.m */; };
A2958CC81B35804600D7AA0F /* CAShapeLayer+JKUIBezierPath.m in Sources */ = {isa = PBXBuildFile; fileRef = A2958CC71B35804600D7AA0F /* CAShapeLayer+JKUIBezierPath.m */; };
A2958CCC1B35808B00D7AA0F /* CATransaction+JKAnimateWithDuration.m in Sources */ = {isa = PBXBuildFile; fileRef = A2958CCB1B35808B00D7AA0F /* CATransaction+JKAnimateWithDuration.m */; };
Expand Down Expand Up @@ -792,8 +791,6 @@
A2958CB61B35794500D7AA0F /* UIView+JKVisuals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+JKVisuals.m"; sourceTree = "<group>"; };
A2958CB81B357AEF00D7AA0F /* UIViewController+JKStoreKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+JKStoreKit.h"; sourceTree = "<group>"; };
A2958CB91B357AEF00D7AA0F /* UIViewController+JKStoreKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+JKStoreKit.m"; sourceTree = "<group>"; };
A2958CBF1B357E2E00D7AA0F /* CAAnimation+Blocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CAAnimation+Blocks.h"; sourceTree = "<group>"; };
A2958CC01B357E2E00D7AA0F /* CAAnimation+Blocks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CAAnimation+Blocks.m"; sourceTree = "<group>"; };
A2958CC21B357E9100D7AA0F /* CAAnimation+JKEasingEquations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CAAnimation+JKEasingEquations.h"; sourceTree = "<group>"; };
A2958CC31B357E9100D7AA0F /* CAAnimation+JKEasingEquations.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CAAnimation+JKEasingEquations.m"; sourceTree = "<group>"; };
A2958CC61B35804600D7AA0F /* CAShapeLayer+JKUIBezierPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CAShapeLayer+JKUIBezierPath.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2511,8 +2508,6 @@
children = (
A2958CC21B357E9100D7AA0F /* CAAnimation+JKEasingEquations.h */,
A2958CC31B357E9100D7AA0F /* CAAnimation+JKEasingEquations.m */,
A2958CBF1B357E2E00D7AA0F /* CAAnimation+Blocks.h */,
A2958CC01B357E2E00D7AA0F /* CAAnimation+Blocks.m */,
);
path = CAAnimation;
sourceTree = "<group>";
Expand Down Expand Up @@ -3062,7 +3057,6 @@
A2B995CA1B46778500011613 /* UIButton+JKTouchAreaInsets.m in Sources */,
C7A8107F1BBA876B00865FFB /* NSObject+JKAppInfo.m in Sources */,
A2FD5B521A5269D400555EA2 /* NSObject+JKRuntime.m in Sources */,
A2958CC11B357E2E00D7AA0F /* CAAnimation+Blocks.m in Sources */,
A281FBEA1AC81392009040DA /* UISearchBarDemoViewController.m in Sources */,
A27E931B1B381D210010C7EA /* UIFont+JKTTF.m in Sources */,
A2EF56E11B21C59C0005F730 /* UIImage+JKBlur.m in Sources */,
Expand Down
56 changes: 51 additions & 5 deletions JKCategories/Foundation/NSDate/NSDate+JKCupertinoYankee.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,24 @@
// THE SOFTWARE.

#import "NSDate+JKCupertinoYankee.h"

#import <UIKit/UIKit.h>
@implementation NSDate (JKCupertinoYankee)

- (NSDate *)jk_beginningOfDay {
NSCalendar *calendar = [NSCalendar currentCalendar];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
NSDateComponents *components;
if ([UIDevice currentDevice].systemVersion.floatValue > 8.0f){
components = [calendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:self];
}else{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
components = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:self];
#pragma clang diagnostic pop
}
#else
NSDateComponents *components = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:self];
#endif

return [calendar dateFromComponents:components];
}
Expand All @@ -42,7 +54,19 @@ - (NSDate *)jk_endOfDay {

- (NSDate *)jk_beginningOfWeek {
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekdayCalendarUnit | NSDayCalendarUnit fromDate:self];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
NSDateComponents *components;
if ([UIDevice currentDevice].systemVersion.floatValue > 8.0f){
components = [calendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitWeekday|NSCalendarUnitDay fromDate:self];
}else{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
components = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekdayCalendarUnit|NSDayCalendarUnit fromDate:self];
#pragma clang diagnostic pop
}
#else
NSDateComponents *components = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit |NSWeekdayCalendarUnit| NSDayCalendarUnit fromDate:self];
#endif

NSUInteger offset = ([components weekday] == [calendar firstWeekday]) ? 6 : [components weekday] - 2;
[components setDay:[components day] - offset];
Expand All @@ -60,8 +84,19 @@ - (NSDate *)jk_endOfWeek {

- (NSDate *)jk_beginningOfMonth {
NSCalendar *calendar = [NSCalendar currentCalendar];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
NSDateComponents *components;
if ([UIDevice currentDevice].systemVersion.floatValue > 8.0f){
components = [calendar components:NSCalendarUnitYear | NSCalendarUnitMonth fromDate:self];
}else{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
components = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit fromDate:self];
#pragma clang diagnostic pop
}
#else
NSDateComponents *components = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit fromDate:self];
#endif
return [calendar dateFromComponents:components];
}

Expand All @@ -76,8 +111,19 @@ - (NSDate *)jk_endOfMonth {

- (NSDate *)jk_beginningOfYear {
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:NSYearCalendarUnit fromDate:self];

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
NSDateComponents *components;
if ([UIDevice currentDevice].systemVersion.floatValue > 8.0f){
components = [calendar components:NSCalendarUnitYear fromDate:self];
}else{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
components = [calendar components:NSYearCalendarUnit fromDate:self];
#pragma clang diagnostic pop
}
#else
NSDateComponents *components = [calendar components:NSYearCalendarUnit fromDate:self];
#endif
return [calendar dateFromComponents:components];
}

Expand Down
Loading

0 comments on commit 0810ada

Please sign in to comment.