-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSSYRecurringDate.h
74 lines (58 loc) · 1.7 KB
/
SSYRecurringDate.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
#import <Cocoa/Cocoa.h>
#define SSRecurringDateWildcard 0x7fff
// Keys to instance variables
extern NSString* const constKeyWeekday ;
extern NSString* const constKeyHour ;
extern NSString* const constKeyMinute ;
/*!
@brief
@details Use the constant NSUndefinedDateComponent to
indicate "any" or "every".
*/
@interface SSYRecurringDate : NSObject <NSCoding, NSCopying> {
NSInteger weekday ;
NSInteger hour ;
NSInteger minute ;
}
@property (assign) NSInteger weekday ;
@property (assign) NSInteger hour ;
@property (assign) NSInteger minute ;
/*!
@details If you are deploying to macOS 10.14+ or iOS 10+, and are using
this to set a timer for an alarm of some kind, consider using
UNCalendarNotificationTrigger instead.
*/
@property (readonly) NSTimeInterval timeIntervalToNextOccurrence;
+ (NSArray*)weekdayChoices ;
+ (NSString*)displayStringForWeekday:(NSInteger)weekday ;
- (NSString*)displayWeekday ;
- (NSString*)displaySummary ;
@end
#if 0
/* TEST CODE */
#import "SSYRecurringDate.h"
- (void)testRecurringDate:(SSYRecurringDate*)rd {
NSTimeInterval ti = [rd timeIntervalToNextOccurrence];
NSDate* nd = [NSDate dateWithTimeIntervalSinceNow:ti];
NSLog(@"%@ : %@ (in %0.1f minutes)", [rd displaySummary], [nd geekDateTimeString], ti / 60);
}
SSYRecurringDate* rd = [SSYRecurringDate new];
rd.weekday = 3;
rd.hour = 5;
rd.minute = 00;
[self testRecurringDate:rd];
rd.hour = 10;
rd.minute = 21;
[self testRecurringDate:rd];
rd.weekday = SSRecurringDateWildcard;
[self testRecurringDate:rd];
rd.hour = 5;
rd.minute = 00;
[self testRecurringDate:rd];
rd.weekday = 3;
[self testRecurringDate:rd];
rd.weekday = 0;
[self testRecurringDate:rd];
rd.weekday = 6;
[self testRecurringDate:rd];
#endif