commit | author | age
|
a0a843
|
1 |
// |
H |
2 |
// TWTRDateUtil.h |
|
3 |
// |
|
4 |
// Created by Kang Chen on 8/4/14. |
|
5 |
// Copyright (c) 2014 Twitter. All rights reserved. |
|
6 |
// |
|
7 |
|
|
8 |
#import <Foundation/Foundation.h> |
|
9 |
|
|
10 |
@interface TWTRDateUtil : NSObject |
|
11 |
|
|
12 |
/** |
|
13 |
* Determines whether the given date is in the current year. |
|
14 |
* |
|
15 |
* @param date the date to determine whether this is in the current year |
|
16 |
* |
|
17 |
* @return whether the date is in the current year |
|
18 |
*/ |
|
19 |
+ (BOOL)isDateInCurrentYear:(NSDate *)date; |
|
20 |
|
|
21 |
/** |
|
22 |
* String suitable for reading out in accessibility label of timestamp. |
|
23 |
* |
|
24 |
* @param date The date to be read out |
|
25 |
* |
|
26 |
* @return The string suitable for reading by VoiceOver |
|
27 |
*/ |
|
28 |
+ (NSString *)accessibilityTextForDate:(NSDate *)date; |
|
29 |
|
|
30 |
/** |
|
31 |
* Checks if two dates are within a certain interval of each other. |
|
32 |
* |
|
33 |
* @param date the future date |
|
34 |
* @param interval time interval to check for |
|
35 |
* @param fromDate the older date to check against |
|
36 |
* |
|
37 |
* @return true if date - fromDate is <= interval |
|
38 |
*/ |
|
39 |
+ (BOOL)isDate:(NSDate *)date withinInterval:(NSTimeInterval)interval fromDate:(NSDate *)fromDate; |
|
40 |
|
|
41 |
/** |
|
42 |
* Checks if two dates are within the same calendar day in UTC. |
|
43 |
* |
|
44 |
* @param date a date |
|
45 |
* @param date2 another date |
|
46 |
* |
|
47 |
* @return true if two dates are within the same calendar day |
|
48 |
*/ |
|
49 |
+ (BOOL)date:(NSDate *)date isWithinSameUTCDayAsDate:(NSDate *)date2; |
|
50 |
|
|
51 |
/** |
|
52 |
* Returns a new date of the specified time in UTC. |
|
53 |
* |
|
54 |
* @param year the 4-digit year e.g. YYYY |
|
55 |
* @param month the month within the year e.g. 1 for Jan, 11 for Nov |
|
56 |
* @param day the day within the month |
|
57 |
* @param hour the hour in 24-hour format e.g. 23 for 11PM |
|
58 |
* @param minute the minute |
|
59 |
* @param second the second |
|
60 |
* |
|
61 |
* @return a new date in the specified UTC time. |
|
62 |
*/ |
|
63 |
+ (NSDate *)UTCDateWithYear:(NSUInteger)year month:(NSUInteger)month day:(NSUInteger)day hour:(NSUInteger)hour minute:(NSUInteger)minute second:(NSUInteger)second; |
|
64 |
@end |