session-ios/Session/Utilities/DateUtil.h

48 lines
1.5 KiB
C
Raw Normal View History

2017-09-19 23:45:18 +02:00
//
2018-02-13 19:06:08 +01:00
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
2017-09-19 23:45:18 +02:00
//
2014-05-06 19:41:08 +02:00
2018-02-13 19:06:08 +01:00
NS_ASSUME_NONNULL_BEGIN
2014-05-06 19:41:08 +02:00
@interface DateUtil : NSObject
+ (NSDateFormatter *)dateFormatter;
+ (NSDateFormatter *)timeFormatter;
+ (NSDateFormatter *)monthAndDayFormatter;
+ (NSDateFormatter *)shortDayOfWeekFormatter;
2018-04-10 20:53:40 +02:00
+ (BOOL)dateIsOlderThanToday:(NSDate *)date;
2014-05-06 19:41:08 +02:00
+ (BOOL)dateIsOlderThanOneWeek:(NSDate *)date;
+ (BOOL)dateIsToday:(NSDate *)date;
+ (BOOL)dateIsThisYear:(NSDate *)date;
2018-04-10 20:53:40 +02:00
+ (BOOL)dateIsYesterday:(NSDate *)date;
2014-05-06 19:41:08 +02:00
2017-09-27 22:38:41 +02:00
+ (NSString *)formatPastTimestampRelativeToNow:(uint64_t)pastTimestamp
2018-06-29 23:00:22 +02:00
NS_SWIFT_NAME(formatPastTimestampRelativeToNow(_:));
2018-06-26 16:17:03 +02:00
+ (NSString *)formatTimestampShort:(uint64_t)timestamp;
+ (NSString *)formatDateShort:(NSDate *)date;
2018-07-05 17:56:46 +02:00
+ (NSString *)formatTimestampAsTime:(uint64_t)timestamp;
+ (NSString *)formatDateAsTime:(NSDate *)date;
2018-07-09 19:55:25 +02:00
+ (NSString *)formatMessageTimestamp:(uint64_t)timestamp;
2018-07-05 17:56:46 +02:00
2018-07-09 19:55:25 +02:00
+ (BOOL)isTimestampFromLastHour:(uint64_t)timestamp;
2018-07-09 22:39:48 +02:00
// These two "exemplary" values can be used by views to measure
// the likely size for recent values formatted using isTimestampFromLastHour:.
2018-07-05 17:56:46 +02:00
+ (NSString *)exemplaryNowTimeFormat;
2018-07-09 19:55:25 +02:00
+ (NSString *)exemplaryMinutesTimeFormat;
+ (NSString *)formatDateForDisplay:(NSDate *)date;
2018-07-09 21:20:58 +02:00
+ (BOOL)isSameDayWithTimestamp:(uint64_t)timestamp1 timestamp:(uint64_t)timestamp2;
+ (BOOL)isSameDayWithDate:(NSDate *)date1 date:(NSDate *)date2;
+ (BOOL)isSameHourWithTimestamp:(uint64_t)timestamp1 timestamp:(uint64_t)timestamp2;
+ (BOOL)isSameHourWithDate:(NSDate *)date1 date:(NSDate *)date2;
2014-05-06 19:41:08 +02:00
@end
2018-02-13 19:06:08 +01:00
NS_ASSUME_NONNULL_END