Skip to content
Browse files

Initial import

  • Loading branch information...
0 parents commit 3a9ccf57417b611bf4d69b5e4b004ced46f4c103 @mattt committed Apr 16, 2012
243 Example/Cupertino Yankee Example.xcodeproj/project.pbxproj
@@ -0,0 +1,243 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ F8D36B2E153D3AF000E60A8B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8D36B2D153D3AF000E60A8B /* Foundation.framework */; };
+ F8D36B31153D3AF000E60A8B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F8D36B30153D3AF000E60A8B /* main.m */; };
+ F8D36B35153D3AF000E60A8B /* Cupertino_Yankee_Example.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = F8D36B34153D3AF000E60A8B /* Cupertino_Yankee_Example.1 */; };
+ F8D36B41153D3B1400E60A8B /* NSDate+CupertinoYankee.m in Sources */ = {isa = PBXBuildFile; fileRef = F8D36B3F153D3B1400E60A8B /* NSDate+CupertinoYankee.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ F8D36B27153D3AF000E60A8B /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = /usr/share/man/man1/;
+ dstSubfolderSpec = 0;
+ files = (
+ F8D36B35153D3AF000E60A8B /* Cupertino_Yankee_Example.1 in CopyFiles */,
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ F8D36B29153D3AF000E60A8B /* Cupertino Yankee Example */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Cupertino Yankee Example"; sourceTree = BUILT_PRODUCTS_DIR; };
+ F8D36B2D153D3AF000E60A8B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ F8D36B30153D3AF000E60A8B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ F8D36B33153D3AF000E60A8B /* Cupertino Yankee Example-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Cupertino Yankee Example-Prefix.pch"; sourceTree = "<group>"; };
+ F8D36B34153D3AF000E60A8B /* Cupertino_Yankee_Example.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = Cupertino_Yankee_Example.1; sourceTree = "<group>"; };
+ F8D36B3F153D3B1400E60A8B /* NSDate+CupertinoYankee.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSDate+CupertinoYankee.m"; path = "../../NSDate+CupertinoYankee.m"; sourceTree = "<group>"; };
+ F8D36B40153D3B1400E60A8B /* NSDate+CupertinoYankee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSDate+CupertinoYankee.h"; path = "../../NSDate+CupertinoYankee.h"; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ F8D36B26153D3AF000E60A8B /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ F8D36B2E153D3AF000E60A8B /* Foundation.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ F8D36B1E153D3AF000E60A8B = {
+ isa = PBXGroup;
+ children = (
+ F8D36B2F153D3AF000E60A8B /* Cupertino Yankee Example */,
+ F8D36B2C153D3AF000E60A8B /* Frameworks */,
+ F8D36B2A153D3AF000E60A8B /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ F8D36B2A153D3AF000E60A8B /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ F8D36B29153D3AF000E60A8B /* Cupertino Yankee Example */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ F8D36B2C153D3AF000E60A8B /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ F8D36B2D153D3AF000E60A8B /* Foundation.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ F8D36B2F153D3AF000E60A8B /* Cupertino Yankee Example */ = {
+ isa = PBXGroup;
+ children = (
+ F8D36B3F153D3B1400E60A8B /* NSDate+CupertinoYankee.m */,
+ F8D36B40153D3B1400E60A8B /* NSDate+CupertinoYankee.h */,
+ F8D36B30153D3AF000E60A8B /* main.m */,
+ F8D36B34153D3AF000E60A8B /* Cupertino_Yankee_Example.1 */,
+ F8D36B32153D3AF000E60A8B /* Supporting Files */,
+ );
+ path = "Cupertino Yankee Example";
+ sourceTree = "<group>";
+ };
+ F8D36B32153D3AF000E60A8B /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ F8D36B33153D3AF000E60A8B /* Cupertino Yankee Example-Prefix.pch */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ F8D36B28153D3AF000E60A8B /* Cupertino Yankee Example */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = F8D36B38153D3AF000E60A8B /* Build configuration list for PBXNativeTarget "Cupertino Yankee Example" */;
+ buildPhases = (
+ F8D36B25153D3AF000E60A8B /* Sources */,
+ F8D36B26153D3AF000E60A8B /* Frameworks */,
+ F8D36B27153D3AF000E60A8B /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "Cupertino Yankee Example";
+ productName = "Cupertino Yankee Example";
+ productReference = F8D36B29153D3AF000E60A8B /* Cupertino Yankee Example */;
+ productType = "com.apple.product-type.tool";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ F8D36B20153D3AF000E60A8B /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ };
+ buildConfigurationList = F8D36B23153D3AF000E60A8B /* Build configuration list for PBXProject "Cupertino Yankee Example" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = F8D36B1E153D3AF000E60A8B;
+ productRefGroup = F8D36B2A153D3AF000E60A8B /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ F8D36B28153D3AF000E60A8B /* Cupertino Yankee Example */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+ F8D36B25153D3AF000E60A8B /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ F8D36B31153D3AF000E60A8B /* main.m in Sources */,
+ F8D36B41153D3B1400E60A8B /* NSDate+CupertinoYankee.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ F8D36B36153D3AF000E60A8B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ F8D36B37153D3AF000E60A8B /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
+ F8D36B39153D3AF000E60A8B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "Cupertino Yankee Example/Cupertino Yankee Example-Prefix.pch";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ F8D36B3A153D3AF000E60A8B /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "Cupertino Yankee Example/Cupertino Yankee Example-Prefix.pch";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ F8D36B23153D3AF000E60A8B /* Build configuration list for PBXProject "Cupertino Yankee Example" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ F8D36B36153D3AF000E60A8B /* Debug */,
+ F8D36B37153D3AF000E60A8B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ F8D36B38153D3AF000E60A8B /* Build configuration list for PBXNativeTarget "Cupertino Yankee Example" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ F8D36B39153D3AF000E60A8B /* Debug */,
+ F8D36B3A153D3AF000E60A8B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = F8D36B20153D3AF000E60A8B /* Project object */;
+}
7 Example/Cupertino Yankee Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:Cupertino Yankee Example.xcodeproj">
+ </FileRef>
+</Workspace>
7 Example/Cupertino Yankee Example/Cupertino Yankee Example-Prefix.pch
@@ -0,0 +1,7 @@
+//
+// Prefix header for all source files of the 'Cupertino Yankee Example' target in the 'Cupertino Yankee Example' project
+//
+
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+#endif
79 Example/Cupertino Yankee Example/Cupertino_Yankee_Example.1
@@ -0,0 +1,79 @@
+.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
+.\"See Also:
+.\"man mdoc.samples for a complete listing of options
+.\"man mdoc for the short list of editing options
+.\"/usr/share/misc/mdoc.template
+.Dd 12/04/16 \" DATE
+.Dt Cupertino Yankee Example 1 \" Program name and manual section number
+.Os Darwin
+.Sh NAME \" Section Header - required - don't modify
+.Nm Cupertino Yankee Example,
+.\" The following lines are read in generating the apropos(man -k) database. Use only key
+.\" words here as the database is built based on the words here and in the .ND line.
+.Nm Other_name_for_same_program(),
+.Nm Yet another name for the same program.
+.\" Use .Nm macro to designate other names for the documented program.
+.Nd This line parsed for whatis database.
+.Sh SYNOPSIS \" Section Header - required - don't modify
+.Nm
+.Op Fl abcd \" [-abcd]
+.Op Fl a Ar path \" [-a path]
+.Op Ar file \" [file]
+.Op Ar \" [file ...]
+.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
+arg2 ... \" Arguments
+.Sh DESCRIPTION \" Section Header - required - don't modify
+Use the .Nm macro to refer to your program throughout the man page like such:
+.Nm
+Underlining is accomplished with the .Ar macro like this:
+.Ar underlined text .
+.Pp \" Inserts a space
+A list of items with descriptions:
+.Bl -tag -width -indent \" Begins a tagged list
+.It item a \" Each item preceded by .It macro
+Description of item a
+.It item b
+Description of item b
+.El \" Ends the list
+.Pp
+A list of flags and their descriptions:
+.Bl -tag -width -indent \" Differs from above in tag removed
+.It Fl a \"-a flag as a list item
+Description of -a flag
+.It Fl b
+Description of -b flag
+.El \" Ends the list
+.Pp
+.\" .Sh ENVIRONMENT \" May not be needed
+.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
+.\" .It Ev ENV_VAR_1
+.\" Description of ENV_VAR_1
+.\" .It Ev ENV_VAR_2
+.\" Description of ENV_VAR_2
+.\" .El
+.Sh FILES \" File used or created by the topic of the man page
+.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
+.It Pa /usr/share/file_name
+FILE_1 description
+.It Pa /Users/joeuser/Library/really_long_file_name
+FILE_2 description
+.El \" Ends the list
+.\" .Sh DIAGNOSTICS \" May not be needed
+.\" .Bl -diag
+.\" .It Diagnostic Tag
+.\" Diagnostic informtion here.
+.\" .It Diagnostic Tag
+.\" Diagnostic informtion here.
+.\" .El
+.Sh SEE ALSO
+.\" List links in ascending order by section, alphabetically within a section.
+.\" Please do not reference files that do not exist without filing a bug report
+.Xr a 1 ,
+.Xr b 1 ,
+.Xr c 1 ,
+.Xr a 2 ,
+.Xr b 2 ,
+.Xr a 3 ,
+.Xr b 3
+.\" .Sh BUGS \" Document known, unremedied bugs
+.\" .Sh HISTORY \" Document history if command behaves in a unique manner
43 Example/Cupertino Yankee Example/main.m
@@ -0,0 +1,43 @@
+// main.m
+//
+// Copyright (c) 2012 Mattt Thompson (http://mattt.me)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+
+#import "NSDate+CupertinoYankee.h"
+
+int main (int argc, const char * argv[]) {
+ @autoreleasepool {
+ NSDate *date = [NSDate date];
+ NSLog(@"Current Time: %@", date);
+ NSLog(@"Beginning of Day:%@", [date beginningOfDay]);
+ NSLog(@"End of Day:%@", [date endOfDay]);
+ NSLog(@"Beginning of Week:%@", [date beginningOfWeek]);
+ NSLog(@"End of Week:%@", [date endOfWeek]);
+ NSLog(@"Beginning of Month:%@", [date beginningOfMonth]);
+ NSLog(@"End of Month:%@", [date endOfMonth]);
+ NSLog(@"Beginning of Year:%@", [date beginningOfYear]);
+ NSLog(@"End of Year:%@", [date endOfYear]);
+ }
+
+ return 0;
+}
+
39 NSDate+CupertinoYankee.h
@@ -0,0 +1,39 @@
+// NSDate+CupertinoYankee.h
+//
+// Copyright (c) 2012 Mattt Thompson (http://mattt.me)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+
+@interface NSDate (CupertinoYankee)
+
+- (NSDate *)beginningOfDay;
+- (NSDate *)endOfDay;
+
+- (NSDate *)beginningOfWeek;
+- (NSDate *)endOfWeek;
+
+- (NSDate *)beginningOfMonth;
+- (NSDate *)endOfMonth;
+
+- (NSDate *)beginningOfYear;
+- (NSDate *)endOfYear;
+
+@end
92 NSDate+CupertinoYankee.m
@@ -0,0 +1,92 @@
+// NSDate+CupertinoYankee.m
+//
+// Copyright (c) 2012 Mattt Thompson (http://mattt.me)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "NSDate+CupertinoYankee.h"
+
+@implementation NSDate (CupertinoYankee)
+
+- (NSDate *)beginningOfDay {
+ NSCalendar *calendar = [NSCalendar currentCalendar];
+ NSDateComponents *components = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:self];
+
+ return [calendar dateFromComponents:components];
+}
+
+- (NSDate *)endOfDay {
+ NSCalendar *calendar = [NSCalendar currentCalendar];
+
+ NSDateComponents *components = [[NSDateComponents alloc] init];
+ [components setDay:1];
+
+ return [[calendar dateByAddingComponents:components toDate:[self beginningOfDay] options:0] dateByAddingTimeInterval:-1];
+}
+
+- (NSDate *)beginningOfWeek {
+ NSCalendar *calendar = [NSCalendar currentCalendar];
+ NSDateComponents *components = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:self];
+
+ [components setWeekday:[calendar firstWeekday]];
+
+ return [calendar dateFromComponents:components];
+}
+
+- (NSDate *)endOfWeek {
+ NSCalendar *calendar = [NSCalendar currentCalendar];
+
+ NSDateComponents *components = [[NSDateComponents alloc] init];
+ [components setWeek:1];
+
+ return [[calendar dateByAddingComponents:components toDate:[self beginningOfWeek] options:0] dateByAddingTimeInterval:-1];}
+
+- (NSDate *)beginningOfMonth {
+ NSCalendar *calendar = [NSCalendar currentCalendar];
+ NSDateComponents *components = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit fromDate:self];
+
+ return [calendar dateFromComponents:components];
+}
+
+- (NSDate *)endOfMonth {
+ NSCalendar *calendar = [NSCalendar currentCalendar];
+
+ NSDateComponents *components = [[NSDateComponents alloc] init];
+ [components setMonth:1];
+
+ return [[calendar dateByAddingComponents:components toDate:[self beginningOfMonth] options:0] dateByAddingTimeInterval:-1];
+}
+
+- (NSDate *)beginningOfYear {
+ NSCalendar *calendar = [NSCalendar currentCalendar];
+ NSDateComponents *components = [calendar components:NSYearCalendarUnit fromDate:self];
+
+ return [calendar dateFromComponents:components];
+}
+
+- (NSDate *)endOfYear {
+ NSCalendar *calendar = [NSCalendar currentCalendar];
+
+ NSDateComponents *components = [[NSDateComponents alloc] init];
+ [components setYear:1];
+
+ return [[calendar dateByAddingComponents:components toDate:[self beginningOfYear] options:0] dateByAddingTimeInterval:-1];
+}
+
+@end

0 comments on commit 3a9ccf5

Please sign in to comment.
Something went wrong with that request. Please try again.