-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNSCalendar+Convenience.h
76 lines (56 loc) · 2.34 KB
/
NSCalendar+Convenience.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
//
// NSCalendar+Convenience.h
// Ringtonic
//
// Created by Alexander Ivanov on 15.11.16.
// Copyright © 2016 Alexander Ivanov. All rights reserved.
//
#import <Foundation/Foundation.h>
#define WEEKDAY_SUNDAY 0 // вс
#define WEEKDAY_MONDAY 1 // пн
#define WEEKDAY_TUESDAY 2 // вт
#define WEEKDAY_WEDNESDAY 3 // ср
#define WEEKDAY_THURSDAY 4 // чт
#define WEEKDAY_FRIDAY 5 // пт
#define WEEKDAY_SATURDAY 6 // сб
#define TIME_SECOND 1
#define TIME_MINUTE 60
#define TIME_HOUR 3600 // 60*60
#define TIME_DAY 86400 // 24*60*60
#define TIME_WEEK 604800 // 7*24*60*60
#define TIME_MONTH 2592000 // 30*24*60*60
#define TIME_YEAR 31536000 // 365*24*60*60
@interface NSDate (Convenience)
- (BOOL)isGreaterThan:(NSDate *)date;
- (BOOL)isLessThan:(NSDate *)date;
- (BOOL)isGreaterThanOrEqual:(NSDate *)date;
- (BOOL)isLessThanOrEqual:(NSDate *)date;
@property (assign, nonatomic, readonly) BOOL isPast;
@property (assign, nonatomic, readonly) BOOL isFuture;
@property (assign, nonatomic, readonly) BOOL isYesterday;
@property (assign, nonatomic, readonly) BOOL isToday;
@property (assign, nonatomic, readonly) BOOL isTomorrow;
@property (assign, nonatomic, readonly) NSUInteger weekday;
@property (assign, nonatomic, readonly) NSInteger daysToNow;
@property (assign, nonatomic, readonly) NSInteger secondsFromGMT;
- (NSInteger)componentValue:(NSCalendarUnit)unit;
- (NSDate *)addValue:(NSInteger)value forComponent:(NSCalendarUnit)unit;
- (NSDate *)component:(NSCalendarUnit)unit;
- (NSDate *)dateComponent;
- (NSTimeInterval)timeComponent;
- (NSDate *)nextWeekday:(NSInteger)weekday withTime:(NSTimeInterval)time skipToday:(BOOL)skipToday;
- (NSDate *)nextWeekday:(NSInteger)weekday withTime:(NSTimeInterval)time;
- (NSDate *)nextDay:(NSInteger)day withTime:(NSTimeInterval)time skipToday:(BOOL)skipToday;
- (NSDate *)nextDay:(NSInteger)day withTime:(NSTimeInterval)time;
+ (NSUInteger)firstWeekday;
+ (NSDate *)yesterday;
+ (NSDate *)today;
+ (NSDate *)tomorrow;
@end
@interface NSDateComponents (Convenience)
+ (NSCalendarUnit)mostSignificantComponent:(NSTimeInterval)ti;
+ (instancetype)dateComponentsWithValue:(NSInteger)value forComponent:(NSCalendarUnit)unit;
+ (instancetype)dateComponentsWithYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day;
- (NSTimeInterval)secondsFromDate:(NSDate *)date;
- (NSTimeInterval)secondsToDate:(NSDate *)date;
@end