Structure
The span of time between a specific start date and end date.
--表示开始日期与结束日期之间的跨度的结构体
iOS, tvOS, watchOS
struct DateInterval
macOS, Mac Catalyst
struct DateInterval, Codable
DateInterval represents a closed date interval in the form of [startDate, endDate]. It is possible for the start and end dates to be the same with a duration of 0. DateInterval does not support reverse intervals i.e. intervals where the duration is less than 0 and the end date occurs earlier in time than the start date.
--DateInterval表示一个封闭的日期间隔,其形式为[startDate, endDate]。开始和结束日期可能相同,持续时间为0。DateInterval不支持反向间隔,即持续时间小于0且结束日期比开始日期早的间隔。
init()
Initializes an interval with start and end dates set to the current date and the duration set to 0
.
--初始化将开始和结束日期设置为当前日期、持续时间设置为0的间隔。
init(start: Date, duration: TimeInterval)
Initializes an interval with the specified start date and duration.
--使用指定的开始日期和持续时间初始化间隔。
init(start: Date, end: Date)
Initializes an interval with the specified start and end date.
--使用指定的开始和结束日期初始化间隔。
var start: Date
The start date.
var end: Date
The end date.
var duration: TimeInterval
The duration.
static func != (DateInterval, DateInterval) -> Bool
Returns a Boolean value indicating whether two values are not equal.
static func < (DateInterval, DateInterval) -> Bool
Indicates whether one date interval is strictly less than another.
static func <= (DateInterval, DateInterval) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func == (DateInterval, DateInterval) -> Bool
Indicates whether two date intervals are the same.
static func > (DateInterval, DateInterval) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func >= (DateInterval, DateInterval) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
func intersection(with: DateInterval) -> DateInterval?
Returns an interval that represents the interval where the given date interval and the current instance intersect.
--返回一个间隔,该间隔表示给定日期间隔与当前实例相交的间隔。
func intersects(DateInterval) -> Bool
Indicates whether this interval intersects the specified interval.
--指示此间隔实例是否与指定的间隔相交。
func contains(Date) -> Bool
Indicates whether this interval contains the given date.
var description: String
A textual description of the date interval.
var debugDescription: String
A textual description of the date interval suitable for debugging.
var customMirror: Mirror
A mirror that reflects the date interval.
--反映日期间隔的镜像。
var hashValue: Int
The computed hash value for the date interval.
class NSDateInterval
An object representing the span of time between two dates that bridges to DateInterval
; use NSDateInterval
when you need reference semantics or other Foundation-specific behavior.
typealias DateInterval.ReferenceType
An alias for this value type's equivalent reference type.
init(from: Decoder)
func compare(DateInterval) -> ComparisonResult
Compares two intervals.
func encode(to: Encoder)
func hash(into: inout Hasher)
static func ... (DateInterval) -> PartialRangeFrom
Returns a partial range extending upward from a lower bound.
static func ... (DateInterval) -> PartialRangeThrough
Returns a partial range up to, and including, its upper bound.
static func ... (DateInterval, DateInterval) -> ClosedRange
Returns a closed range that contains both of its bounds.
static func ..< (DateInterval) -> PartialRangeUpTo
Returns a partial range up to, but not including, its upper bound.
static func ..< (DateInterval, DateInterval) -> Range
Returns a half-open range that contains its lower bound but not its upper bound.
Comparable
CustomDebugStringConvertible
CustomReflectable
CustomStringConvertible
Decodable
Encodable
Hashable
ReferenceConvertible
struct Date
A specific point in time, independent of any calendar or time zone.
typealias TimeInterval
A number of seconds.