Skip to content

Commit

Permalink
NSDate+JKZeroDate
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakey committed Nov 26, 2016
1 parent 00cce1a commit 315d734
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
6 changes: 6 additions & 0 deletions JKCategories-Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
A2C97D861C96576E00614B98 /* UICollectionViewDemoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2C97D841C96576E00614B98 /* UICollectionViewDemoViewController.xib */; };
A2CFAEF51A56BD050004A282 /* NSString+JKScore.m in Sources */ = {isa = PBXBuildFile; fileRef = A2CFAEF41A56BD050004A282 /* NSString+JKScore.m */; };
A2CFAEF81A56D15C0004A282 /* UIColor+JKModify.m in Sources */ = {isa = PBXBuildFile; fileRef = A2CFAEF71A56D15C0004A282 /* UIColor+JKModify.m */; };
A2D4AFF61DE950C700DA0C3F /* NSDate+JKZeroDate.m in Sources */ = {isa = PBXBuildFile; fileRef = A2D4AFF51DE950C700DA0C3F /* NSDate+JKZeroDate.m */; };
A2E305651BA927E10006BE4E /* NSURLRequest+JKParamsFromDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = A2E305641BA927E10006BE4E /* NSURLRequest+JKParamsFromDictionary.m */; };
A2E3056D1BA92A110006BE4E /* NSURLRequestDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A2E3056B1BA92A110006BE4E /* NSURLRequestDemoViewController.m */; };
A2E3056E1BA92A110006BE4E /* NSURLRequestDemoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2E3056C1BA92A110006BE4E /* NSURLRequestDemoViewController.xib */; };
Expand Down Expand Up @@ -891,6 +892,8 @@
A2CFAEF41A56BD050004A282 /* NSString+JKScore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+JKScore.m"; sourceTree = "<group>"; };
A2CFAEF61A56D15C0004A282 /* UIColor+JKModify.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+JKModify.h"; sourceTree = "<group>"; };
A2CFAEF71A56D15C0004A282 /* UIColor+JKModify.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+JKModify.m"; sourceTree = "<group>"; };
A2D4AFF41DE950C700DA0C3F /* NSDate+JKZeroDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+JKZeroDate.h"; sourceTree = "<group>"; };
A2D4AFF51DE950C700DA0C3F /* NSDate+JKZeroDate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+JKZeroDate.m"; sourceTree = "<group>"; };
A2E305631BA927E10006BE4E /* NSURLRequest+JKParamsFromDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSURLRequest+JKParamsFromDictionary.h"; sourceTree = "<group>"; };
A2E305641BA927E10006BE4E /* NSURLRequest+JKParamsFromDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURLRequest+JKParamsFromDictionary.m"; sourceTree = "<group>"; };
A2E305661BA929700006BE4E /* NSMutableURLRequest+JKUpload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableURLRequest+JKUpload.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1576,6 +1579,8 @@
A20FFDF91B4F944A00600093 /* NSDate+JKInternetDateTime.m */,
A28141B71B5BCA0500496E75 /* NSDate+JKCupertinoYankee.h */,
A28141B81B5BCA0500496E75 /* NSDate+JKCupertinoYankee.m */,
A2D4AFF41DE950C700DA0C3F /* NSDate+JKZeroDate.h */,
A2D4AFF51DE950C700DA0C3F /* NSDate+JKZeroDate.m */,
);
path = NSDate;
sourceTree = "<group>";
Expand Down Expand Up @@ -3138,6 +3143,7 @@
A2C12BA21B1C282C00EAD198 /* UITableView+JKiOS7Style.m in Sources */,
A2681A441A75C7C8009BA7EE /* NSString+JKEncrypt.m in Sources */,
A24EC2E31B74D69E00CE538B /* NSRunLoopDemoViewController.m in Sources */,
A2D4AFF61DE950C700DA0C3F /* NSDate+JKZeroDate.m in Sources */,
A284C0FE1AEB908100D90ED5 /* UIBezierPath+JKBasicShapes.m in Sources */,
A29EC2681B527A19008ABB42 /* UIPopoverController+iPhone.m in Sources */,
A2E305651BA927E10006BE4E /* NSURLRequest+JKParamsFromDictionary.m in Sources */,
Expand Down
17 changes: 17 additions & 0 deletions JKCategories/Foundation/NSDate/NSDate+JKZeroDate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// NSDate+JKZeroDate.h
// Jakey
//
// Created by Jakey on 15/5/9.
// Copyright (c) 2015年 Jakey. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSDate (JKZeroDate)
+ (NSDate *)jk_zeroTodayDate;
+ (NSDate *)jk_zero24TodayDate;

- (NSDate *)jk_zeroDate;
- (NSDate *)jk_zero24Date;
@end
50 changes: 50 additions & 0 deletions JKCategories/Foundation/NSDate/NSDate+JKZeroDate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// NSDate+JKZeroDate.m
// Jakey
//
// Created by Jakey on 15/5/9.
// Copyright (c) 2015年 Jakey. All rights reserved.
//

#import "NSDate+JKZeroDate.h"

@implementation NSDate (JKZeroDate)
+ (NSDate *)jk_zeroTodayDate
{
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:NSUIntegerMax fromDate:[NSDate date]];
components.hour = 0;
components.minute = 0;
components.second = 0;
return [calendar dateFromComponents:components];
}

+ (NSDate *)jk_zero24TodayDate
{
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:NSUIntegerMax fromDate:[NSDate date]];
components.hour = 23;
components.minute = 59;
components.second = 0;
return [calendar dateFromComponents:components];
}

- (NSDate *)jk_zeroDate
{
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:NSUIntegerMax fromDate:self];
components.hour = 0;
components.minute = 0;
components.second = 0;
return [calendar dateFromComponents:components];
}
- (NSDate *)jk_zero24Date
{
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:NSUIntegerMax fromDate:self];
components.hour = 23;
components.minute = 59;
components.second = 0;
return [calendar dateFromComponents:components];
}
@end
1 change: 1 addition & 0 deletions JKCategories/JKFoundation.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#import "NSDate+JKInternetDateTime.h"
#import "NSDate+JKReporting.h"
#import "NSDate+JKUtilities.h"
#import "NSDate+JKZeroDate.h"
#import "NSDateFormatter+JKMake.h"
#import "NSDecimalNumber+JKCalculatingByString.h"
#import "NSDecimalNumber+JKExtensions.h"
Expand Down

0 comments on commit 315d734

Please sign in to comment.