From 44f21a0c44b7de625b427e2ef26e587ccf5953fd Mon Sep 17 00:00:00 2001 From: yuanshichong Date: Wed, 31 Dec 2014 16:23:35 +0800 Subject: [PATCH] And day time (20141225) --- NSDate+Helper.h | 1 + NSDate+Helper.m | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/NSDate+Helper.h b/NSDate+Helper.h index c682d26..b65f2d3 100644 --- a/NSDate+Helper.h +++ b/NSDate+Helper.h @@ -38,6 +38,7 @@ + (NSDateFormatter *)sharedDateFormatter; - (NSUInteger)daysAgo; - (NSUInteger)daysAgoAgainstMidnight; +- (NSInteger)dayTime; //reture 20141225 - (NSString *)stringDaysAgo; - (NSString *)stringDaysAgoAgainstMidnight:(BOOL)flag; - (NSUInteger)weekday; diff --git a/NSDate+Helper.m b/NSDate+Helper.m index a7f8dfe..d656184 100644 --- a/NSDate+Helper.m +++ b/NSDate+Helper.m @@ -331,4 +331,17 @@ + (NSString *)dbFormatString { return [NSDate timestampFormatString]; } +- (NSInteger)dayTime +{ + [[self class] initializeStatics]; + NSString *dbDateString = [self string]; + NSRange yearRange = NSMakeRange(0, 4); + NSRange monthRange = NSMakeRange(5, 2); + NSRange dayRange = NSMakeRange(8, 2); + NSInteger year = [[dbDateString substringWithRange:yearRange] integerValue]; + NSInteger month = [[dbDateString substringWithRange:monthRange] integerValue]; + NSInteger day = [[dbDateString substringWithRange:dayRange] integerValue]; + NSInteger time = year *10000 + month*100 + day; + return time; +} @end