20200714--iOS之DateInterval结构体,表征日期间隔

Structure

DateInterval

The span of time between a specific start date and end date.

--表示开始日期与结束日期之间的跨度的结构体

 

Declaration     --声明

iOS, tvOS, watchOS

struct DateInterval

macOS, Mac Catalyst

struct DateInterval, Codable

Overview           --概览

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且结束日期比开始日期早的间隔。

 

Topics      --专题

Creating a Date Interval        --创建日期间隔结构体

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.

--使用指定的开始和结束日期初始化间隔。

 

Accessing Start Date, End Date, and Duration        --访问开始、结束日期,时间间隔

var start: Date

The start date.

var end: Date

The end date.

var duration: TimeInterval

The duration.

 

Comparing Date Intervals              --比较日期间隔

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.

 

Determining Intersections               --确定两个间隔实例的交集

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.

--指示此间隔实例是否与指定的间隔相交。

 

Determining Whether a Date Occurs Within a Date Interval        

--确定某个日期是否在某个日期间隔内发生

func contains(Date) -> Bool

Indicates whether this interval contains the given date.

 

Describing a Date Interval            --描述日期间隔实例

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.

 

Using Reference Types         --使用引用类型

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.

 

Initializers         --构造器

init(from: Decoder)

 

Instance Methods          --实例方法

func compare(DateInterval) -> ComparisonResult

Compares two intervals.

func encode(to: Encoder)

func hash(into: inout Hasher)

Operator Functions         --操作符函数

static func ... (DateInterval) -> PartialRangeFrom<DateInterval>

Returns a partial range extending upward from a lower bound.

static func ... (DateInterval) -> PartialRangeThrough<DateInterval>

Returns a partial range up to, and including, its upper bound.

static func ... (DateInterval, DateInterval) -> ClosedRange<DateInterval>

Returns a closed range that contains both of its bounds.

static func ..< (DateInterval) -> PartialRangeUpTo<DateInterval>

Returns a partial range up to, but not including, its upper bound.

static func ..< (DateInterval, DateInterval) -> Range<DateInterval>

Returns a half-open range that contains its lower bound but not its upper bound.

 

Relationships         --继承关系

Conforms To

See Also

Date Representations

struct Date

A specific point in time, independent of any calendar or time zone.

typealias TimeInterval

A number of seconds.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值