forked from bmouse1006/JZB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSDate+Helper.h
93 lines (66 loc) · 2.16 KB
/
NSDate+Helper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// NSDate+Helper.h
// JZB
//
// Created by Jin Jin on 11-4-15.
// Copyright 2011年 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSDate (NSDate_Helper)
//获取年月日如:19871127.
- (NSString *)getFormatYearMonthDay;
//返回当前月一共有几周(可能为4,5,6)
- (int )getWeekNumOfMonth;
//该日期是该年的第几周
- (int )getWeekOfYear;
//返回day天后的日期(若day为负数,则为|day|天前的日期)
- (NSDate *)dateAfterDay:(int)day;
//month个月后的日期
- (NSDate *)dateafterMonth:(int)month;
//获取日
- (NSUInteger)getDay;
//获取月
- (NSUInteger)getMonth;
//获取年
- (NSUInteger)getYear;
//获取小时
- (int )getHour ;
//获取分钟
- (int)getMinute ;
- (int )getHour:(NSDate *)date ;
- (int)getMinute:(NSDate *)date ;
//在当前日期前几天
- (NSUInteger)daysAgo ;
//午夜时间距今几天
- (NSUInteger)daysAgoAgainstMidnight ;
- (NSString *)stringDaysAgo ;
- (NSString *)stringDaysAgoAgainstMidnight:(BOOL)flag;
//返回一周的第几天(周末为第一天)
- (NSUInteger)weekday ;//转为NSString类型的
+ (NSDate *)dateFromString:(NSString *)string ;
+ (NSDate *)dateFromString:(NSString *)string withFormat:(NSString *)format ;
+ (NSString *)stringFromDate:(NSDate *)date withFormat:(NSString *)format ;
+ (NSString *)stringFromDate:(NSDate *)date ;
+ (NSString *)stringForDisplayFromDate:(NSDate *)date prefixed:(BOOL)prefixed ;
+ (NSString *)stringForDisplayFromDate:(NSDate *)date ;
- (NSString *)stringWithFormat:(NSString *)format;
- (NSString *)string ;
- (NSString *)stringWithDateStyle:(NSDateFormatterStyle)dateStyle timeStyle:(NSDateFormatterStyle)timeStyle;
//返回周日的的开始时间
- (NSDate *)beginningOfWeek;
//返回当前天的年月日.
- (NSDate *)beginningOfDay ;
//返回该月的第一天
- (NSDate *)beginningOfMonth;
//该月的最后一天
- (NSDate *)endOfMonth;
//返回当前周的周末
- (NSDate *)endOfWeek ;
//return RFC 822 timestamp
-(double)RFC822TimeInteral;
+ (NSString *)dateFormatString ;
+ (NSString *)timeFormatString ;
+ (NSString *)timestampFormatString ;
// preserving for compatibility
+ (NSString *)dbFormatString ;
@end