Created
February 23, 2014 12:33
-
-
Save 4PixelsDev/9170795 to your computer and use it in GitHub Desktop.
IOS: NSDateComponents extension with methods to determine whether current Year
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSDateComponents+Extended.h | |
// FBBirthdays | |
// | |
// Created by Igor on 2/23/14. | |
// Copyright (c) 2014 4Pixels. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSDateComponents (Extended) | |
/** | |
* Returns YES if year property is leap year, NO otherwise. | |
* | |
* @return YES if year property is leap year, NO otherwise. | |
*/ | |
- (BOOL) isLeapYear; | |
/** | |
* Returns YES if passed year is leap year, NO otherwise. | |
* | |
* @param year the number of year which should determine is it leap or not. | |
* | |
* @return YES if passed year is leap year, NO otherwise. | |
*/ | |
- (BOOL) isLeapYear:(NSInteger)year; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSDateComponents+Extended.m | |
// FBBirthdays | |
// | |
// Created by Igor on 2/23/14. | |
// Copyright (c) 2014 4Pixels. All rights reserved. | |
// | |
#import "NSDateComponents+Extended.h" | |
@implementation NSDateComponents (Extended) | |
- (BOOL) isLeapYear | |
{ | |
return ((self.year % 4 == 0) && (self.year % 100 != 0)) || (self.year % 400 == 0); | |
} | |
- (BOOL) isLeapYear:(NSInteger)year | |
{ | |
return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment