commit | author | age
|
655e66
|
1 |
/* |
H |
2 |
* Copyright (C) 2017 Twitter, Inc. |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
* |
|
16 |
*/ |
|
17 |
|
a0a843
|
18 |
#import <Foundation/Foundation.h> |
H |
19 |
|
|
20 |
@interface TWTRDateUtil : NSObject |
|
21 |
|
|
22 |
/** |
|
23 |
* Determines whether the given date is in the current year. |
|
24 |
* |
|
25 |
* @param date the date to determine whether this is in the current year |
|
26 |
* |
|
27 |
* @return whether the date is in the current year |
|
28 |
*/ |
|
29 |
+ (BOOL)isDateInCurrentYear:(NSDate *)date; |
|
30 |
|
|
31 |
/** |
|
32 |
* String suitable for reading out in accessibility label of timestamp. |
|
33 |
* |
|
34 |
* @param date The date to be read out |
|
35 |
* |
|
36 |
* @return The string suitable for reading by VoiceOver |
|
37 |
*/ |
|
38 |
+ (NSString *)accessibilityTextForDate:(NSDate *)date; |
|
39 |
|
|
40 |
/** |
|
41 |
* Checks if two dates are within a certain interval of each other. |
|
42 |
* |
|
43 |
* @param date the future date |
|
44 |
* @param interval time interval to check for |
|
45 |
* @param fromDate the older date to check against |
|
46 |
* |
|
47 |
* @return true if date - fromDate is <= interval |
|
48 |
*/ |
|
49 |
+ (BOOL)isDate:(NSDate *)date withinInterval:(NSTimeInterval)interval fromDate:(NSDate *)fromDate; |
|
50 |
|
|
51 |
/** |
|
52 |
* Checks if two dates are within the same calendar day in UTC. |
|
53 |
* |
|
54 |
* @param date a date |
|
55 |
* @param date2 another date |
|
56 |
* |
|
57 |
* @return true if two dates are within the same calendar day |
|
58 |
*/ |
|
59 |
+ (BOOL)date:(NSDate *)date isWithinSameUTCDayAsDate:(NSDate *)date2; |
|
60 |
|
|
61 |
/** |
|
62 |
* Returns a new date of the specified time in UTC. |
|
63 |
* |
|
64 |
* @param year the 4-digit year e.g. YYYY |
|
65 |
* @param month the month within the year e.g. 1 for Jan, 11 for Nov |
|
66 |
* @param day the day within the month |
|
67 |
* @param hour the hour in 24-hour format e.g. 23 for 11PM |
|
68 |
* @param minute the minute |
|
69 |
* @param second the second |
|
70 |
* |
|
71 |
* @return a new date in the specified UTC time. |
|
72 |
*/ |
|
73 |
+ (NSDate *)UTCDateWithYear:(NSUInteger)year month:(NSUInteger)month day:(NSUInteger)day hour:(NSUInteger)hour minute:(NSUInteger)minute second:(NSUInteger)second; |
|
74 |
@end |