Commits

Daniel Tull committed 3846d9c

Added date checking methods to NSDate to see if it is today.

Comments (0)

Files changed (3)

DTFoundation.xcodeproj/project.pbxproj

 		241E2A2010F6A11E0076D698 /* NSString+DTPrefixString.m in Sources */ = {isa = PBXBuildFile; fileRef = 24083D2010CF9922009B758E /* NSString+DTPrefixString.m */; };
 		241E2A2110F6A11F0076D698 /* NSDate+DTHTTPDateStrings.h in Headers */ = {isa = PBXBuildFile; fileRef = 24ECCBDF10DC028100AB1388 /* NSDate+DTHTTPDateStrings.h */; };
 		241E2A2210F6A11F0076D698 /* NSDate+DTHTTPDateStrings.m in Sources */ = {isa = PBXBuildFile; fileRef = 24ECCBE010DC028100AB1388 /* NSDate+DTHTTPDateStrings.m */; };
+		24B276081164100700BB3435 /* NSDate+DTDateCheck.m in Sources */ = {isa = PBXBuildFile; fileRef = 24B276071164100700BB3435 /* NSDate+DTDateCheck.m */; };
 		24ECCBE110DC028100AB1388 /* NSDate+DTHTTPDateStrings.m in Sources */ = {isa = PBXBuildFile; fileRef = 24ECCBE010DC028100AB1388 /* NSDate+DTHTTPDateStrings.m */; };
 		288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; };
 		28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; };
 		24083D1F10CF9922009B758E /* NSString+DTPrefixString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+DTPrefixString.h"; sourceTree = "<group>"; };
 		24083D2010CF9922009B758E /* NSString+DTPrefixString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+DTPrefixString.m"; sourceTree = "<group>"; };
 		241E2A0A10F6A0F50076D698 /* libDTFoundation.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDTFoundation.a; sourceTree = BUILT_PRODUCTS_DIR; };
+		24B276061164100700BB3435 /* NSDate+DTDateCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+DTDateCheck.h"; sourceTree = "<group>"; };
+		24B276071164100700BB3435 /* NSDate+DTDateCheck.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+DTDateCheck.m"; sourceTree = "<group>"; };
 		24ECCBDF10DC028100AB1388 /* NSDate+DTHTTPDateStrings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+DTHTTPDateStrings.h"; sourceTree = "<group>"; };
 		24ECCBE010DC028100AB1388 /* NSDate+DTHTTPDateStrings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+DTHTTPDateStrings.m"; sourceTree = "<group>"; };
 		288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
 				24083D1810CF9922009B758E /* NSArray+DTExtras.m */,
 				24083D1910CF9922009B758E /* NSDate+DTComponentExtension.h */,
 				24083D1A10CF9922009B758E /* NSDate+DTComponentExtension.m */,
+				24B276061164100700BB3435 /* NSDate+DTDateCheck.h */,
+				24B276071164100700BB3435 /* NSDate+DTDateCheck.m */,
 				24083D1B10CF9922009B758E /* NSNumber+DTMaths.h */,
 				24083D1C10CF9922009B758E /* NSNumber+DTMaths.m */,
 				24083D1D10CF9922009B758E /* NSSet+DTExtras.h */,
 				24083D2910CF9922009B758E /* NSSet+DTExtras.m in Sources */,
 				24083D2A10CF9922009B758E /* NSString+DTPrefixString.m in Sources */,
 				24ECCBE110DC028100AB1388 /* NSDate+DTHTTPDateStrings.m in Sources */,
+				24B276081164100700BB3435 /* NSDate+DTDateCheck.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

DTFoundation/NSDate+DTDateCheck.h

+//
+//  NSDate+DTDateCheck.h
+//  DTFoundation
+//
+//  Created by Daniel Tull on 01.04.2010.
+//  Copyright 2010 Daniel Tull. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface NSDate (DTDateCheck)
+
+- (BOOL)isToday;
+
+@end

DTFoundation/NSDate+DTDateCheck.m

+//
+//  NSDate+DTDateCheck.m
+//  DTFoundation
+//
+//  Created by Daniel Tull on 01.04.2010.
+//  Copyright 2010 Daniel Tull. All rights reserved.
+//
+
+#import "NSDate+DTDateCheck.h"
+#import "NSDate+DTComponentExtension.h"
+
+@implementation NSDate (DTDateCheck)
+
+- (BOOL)isToday {
+	
+	NSDateComponents *comps = [self gregorianCalendarComponents];
+	NSDateComponents *nowComponents = [[NSDate date] gregorianCalendarComponents];
+	
+	if ([comps day] != [nowComponents day] ||
+		[comps month] != [nowComponents month] ||
+		[comps year] != [nowComponents year] ||
+		[comps era] != [comps era]) {
+		
+		return NO;
+	}
+	
+	return YES;
+}
+
+@end