StructureFoundation5.9.0
Date
Date
represents a single point in time.
struct Date
A Date
is independent of a particular calendar or time zone. To represent a Date
to a user, you must interpret it in the context of a Calendar
.
Citizens in Foundation
Conformances
protocol Comparable
A type that can be compared using the relational operators
<
,<=
,>=
, and>
.protocol CustomDebugStringConvertible
A type with a customized textual representation suitable for debugging purposes.
protocol CustomPlaygroundDisplayConvertible
A type that supplies a custom description for playground logging.
protocol CustomReflectable
A type that explicitly supplies its own mirror.
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Decodable
A type that can decode itself from an external representation.
protocol Encodable
A type that can encode itself to an external representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol ReferenceConvertible
Decorates types which are backed by a Foundation reference type.
Members
init(
) Returns a
Date
initialized to the current date and time.init(from: Decoder
) throws init(timeInterval: TimeInterval, since: Date
) Returns a
Date
initialized relative to another given date by a given number of seconds.init(timeIntervalSince1970: TimeInterval
) Returns a
Date
initialized relative to 00:00:00 UTC on 1 January 1970 by a given number of seconds.init(timeIntervalSinceNow: TimeInterval
) Returns a
Date
initialized relative to the current date and time by a given number of seconds.init(timeIntervalSinceReferenceDate: TimeInterval
) Returns a
Date
initialized relative to 00:00:00 UTC on 1 January 2001 by a given number of seconds.static let distantFuture: Date
Creates and returns a Date value representing a date in the distant future.
static let distantPast: Date
Creates and returns a Date value representing a date in the distant past.
static var now: Date
Returns a
Date
initialized to the current date and time.static let timeIntervalBetween1970AndReferenceDate: TimeInterval
The number of seconds from 1 January 1970 to the reference date, 1 January 2001.
static var timeIntervalSinceReferenceDate: TimeInterval
The interval between 00:00:00 UTC on 1 January 2001 and the current date and time.
var customMirror: Mirror
var debugDescription: String
var description: String
A string representation of the date object (read-only).
var playgroundDescription: Any
var timeIntervalSince1970: TimeInterval
The interval between the date object and 00:00:00 UTC on 1 January 1970.
var timeIntervalSinceNow: TimeInterval
The time interval between the date and the current date and time.
var timeIntervalSinceReferenceDate: TimeInterval
Returns the interval between the date object and 00:00:00 UTC on 1 January 2001.
static func + (Date, TimeInterval
) -> Date Returns a
Date
with a specified amount of time added to it.static func += (inout Date, TimeInterval
) Add a
TimeInterval
to aDate
.static func - (Date, TimeInterval
) -> Date Returns a
Date
with a specified amount of time subtracted from it.static func -= (inout Date, TimeInterval
) Subtract a
TimeInterval
from aDate
.static func < (Date, Date
) -> Bool Returns true if the left hand
Date
is earlier in time than the right handDate
.static func == (Date, Date
) -> Bool Returns true if the two
Date
values represent the same point in time.static func > (Date, Date
) -> Bool Returns true if the left hand
Date
is later in time than the right handDate
.func addTimeInterval(TimeInterval
) Add a
TimeInterval
to thisDate
.func addingTimeInterval(TimeInterval
) -> Date Return a new
Date
by adding aTimeInterval
to thisDate
.func advanced(by: TimeInterval
) -> Date Creates a new date value by adding a
TimeInterval
to thisDate
.func compare(Date
) -> ComparisonResult Compare two
Date
values.func description(with: Locale?
) -> String Returns a string representation of the receiver using the given locale.
func distance(to: Date
) -> TimeInterval Returns the
TimeInterval
between thisDate
and another given date.func encode(to: Encoder
) throws func hash(into: inout Hasher
) func timeIntervalSince(Date
) -> TimeInterval Returns the interval between the receiver and another given date.
typealias ReferenceType
typealias Stride
Features
var halfWidthCornerQuoted: String
static func != (Self, Self
) -> Bool static func ... (Self
) -> PartialRangeFrom<Self> Returns a partial range extending upward from a lower bound.
static func ... (Self
) -> PartialRangeThrough<Self> Returns a partial range up to, and including, its upper bound.
static func ... (Self, Self
) -> ClosedRange<Self> Returns a closed range that contains both of its bounds.
static func ..< (Self
) -> PartialRangeUpTo<Self> Returns a partial range up to, but not including, its upper bound.
static func ..< (Self, Self
) -> Range<Self> Returns a half-open range that contains its lower bound but not its upper bound.
Extension in BSON
Conformances
protocol Primitive
protocol PrimitiveEncodable
protocol Sendable
A type whose values can safely be passed across concurrency domains by copying.
Features
Extension in Vapor
Members
init?(rfc1123: String
) Creates a
Date
from an RFC1123 stringvar rfc1123: String
Formats a
Date
as RFC1123