CFDateInterval.h
1 /* CFDateInterval.h 2 Copyright (c) 2004-2019, Apple Inc. and the Swift project authors 3 4 Portions Copyright (c) 2014-2019, Apple Inc. and the Swift project authors 5 Licensed under Apache License v2.0 with Runtime Library Exception 6 See http://swift.org/LICENSE.txt for license information 7 See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors 8 */ 9 10 #if !defined(__COREFOUNDATION_CFDATEINTERVAL__) 11 #define __COREFOUNDATION_CFDATEINTERVAL__ 1 12 13 #include <CoreFoundation/CFBase.h> 14 #include <CoreFoundation/CFDate.h> 15 16 CF_IMPLICIT_BRIDGING_ENABLED 17 CF_EXTERN_C_BEGIN 18 CF_ASSUME_NONNULL_BEGIN 19 20 typedef struct __CFDateInterval * CFDateIntervalRef; 21 22 CF_EXPORT CFDateIntervalRef CFDateIntervalCreate(CFAllocatorRef _Nullable allocator, CFDateRef startDate, CFTimeInterval duration) API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)); 23 24 CF_EXPORT CFDateIntervalRef CFDateIntervalCreateWithEndDate(CFAllocatorRef _Nullable allocator, CFDateRef startDate, CFDateRef endDate) API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)); 25 26 CF_EXPORT CFTimeInterval CFDateIntervalGetDuration(CFDateIntervalRef interval) API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)); 27 28 CF_EXPORT CFDateRef CFDateIntervalCopyStartDate(CFDateIntervalRef interval) API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)); 29 30 CF_EXPORT CFDateRef CFDateIntervalCopyEndDate(CFDateIntervalRef interval) API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)); 31 32 /* 33 Comparison prioritizes ordering by start date. If the start dates are equal, then it will order by duration. 34 e.g. 35 Given intervals a and b 36 a. |-----| 37 b. |-----| 38 CFDateIntervalCompare(a, b) would return kCFCompareLessThan because a's startDate is earlier in time than b's start date. 39 40 In the event that the start dates are equal, the compare method will attempt to order by duration. 41 e.g. 42 Given intervals c and d 43 c. |-----| 44 d. |---| 45 CFDateIntervalCompare(c, d)would result in kCFCompareGreaterThan because c is longer than d. 46 47 If both the start dates and the durations are equal, then the intervals are considered equal and kCFCompareEqualTo is returned as the result. 48 */ 49 CF_EXPORT CFComparisonResult CFDateIntervalCompare(CFDateIntervalRef interval1, CFDateIntervalRef interval2) API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)); 50 51 CF_EXPORT Boolean CFDateIntervalIntersectsDateInterval(CFDateIntervalRef interval, CFDateIntervalRef intervalToIntersect) API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)); 52 53 CF_EXPORT CFDateIntervalRef _Nullable CFDateIntervalCreateIntersectionWithDateInterval(CFAllocatorRef _Nullable allocator, CFDateIntervalRef interval, CFDateIntervalRef intervalToIntersect) API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)); 54 55 CF_EXPORT Boolean CFDateIntervalContainsDate(CFDateIntervalRef interval, CFDateRef date) API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)); 56 57 CF_ASSUME_NONNULL_END 58 CF_EXTERN_C_END 59 CF_IMPLICIT_BRIDGING_DISABLED 60 61 #endif 62