var customMirror: Mirror
var debugDescription: String
var description: String
var firstWeekday: Int
The first weekday of the calendar.
var identifier: Calendar.Identifier
The identifier of the calendar.
var locale: Locale?
The locale of the calendar.
var minimumDaysInFirstWeek: Int
The number of minimum days in the first week.
var timeZone: TimeZone
The time zone of the calendar.
func compare(Date, to: Date, toGranularity: Calendar.Component) -> ComparisonResult
Compares the given dates down to the given component, reporting them orderedSame
if they are the same in the given component and all larger components, otherwise either orderedAscending
or orderedDescending
.
func component(Calendar.Component, from: Date) -> Int
Returns the value for one component of a date.
func date(Date, matchesComponents: DateComponents) -> Bool
Determine if the Date
has all of the specified DateComponents
.
func date(byAdding: DateComponents, to: Date, wrappingComponents: Bool) -> Date?
Returns a new Date
representing the date calculated by adding components to a given date.
func date(byAdding: Calendar.Component, value: Int, to: Date, wrappingComponents: Bool) -> Date?
Returns a new Date
representing the date calculated by adding an amount of a specific component to a given date.
func date(bySetting: Calendar.Component, value: Int, of: Date) -> Date?
Returns a new Date
representing the date calculated by setting a specific component to a given time, and trying to keep lower components the same. If the component already has that value, this may result in a date which is the same as the given date.
func date(bySettingHour: Int, minute: Int, second: Int, of: Date, matchingPolicy: Calendar.MatchingPolicy, repeatedTimePolicy: Calendar.RepeatedTimePolicy, direction: Calendar.SearchDirection) -> Date?
Returns a new Date
representing the date calculated by setting hour, minute, and second to a given time on a specified Date
.
func date(from: DateComponents) -> Date?
Returns a date created from the specified components.
func dateComponents(Set<Calendar.Component>, from: Date) -> DateComponents
Returns all the date components of a date, using the calendar time zone.
func dateComponents(Set<Calendar.Component>, from: DateComponents, to: DateComponents) -> DateComponents
Returns the difference between two dates specified as DateComponents
.
func dateComponents(Set<Calendar.Component>, from: Date, to: Date) -> DateComponents
Returns the difference between two dates.
func dateComponents(in: TimeZone, from: Date) -> DateComponents
Returns all the date components of a date, as if in a given time zone (instead of the Calendar
time zone).
func dateInterval(of: Calendar.Component, for: Date) -> DateInterval?
Returns the starting time and duration of a given calendar component that contains a given date.
func dateInterval(of: Calendar.Component, start: inout Date, interval: inout TimeInterval, for: Date) -> Bool
Returns, via two inout parameters, the starting time and duration of a given calendar component that contains a given date.
func dateIntervalOfWeekend(containing: Date) -> DateInterval?
Returns a DateInterval
of the weekend contained by the given date, or nil if the date is not in a weekend.
func dateIntervalOfWeekend(containing: Date, start: inout Date, interval: inout TimeInterval) -> Bool
Finds the range of the weekend around the given date, and returns the starting date and duration of the weekend via two inout parameters.
func dates(byAdding: DateComponents, startingAt: Date, in: Range<Date>?, wrappingComponents: Bool) -> some Sendable & Sequence<Date>
Returns a sequence of Date
s, calculated by repeatedly adding an amount of DateComponents
to a starting Date
and then to each subsequent result. If a range is supplied, the sequence terminates if the next result is not contained in the range. The starting point does not need to be contained in the range, but if the first result is outside of the range then the result will be an empty sequence.
func dates(byAdding: Calendar.Component, value: Int, startingAt: Date, in: Range<Date>?, wrappingComponents: Bool) -> some Sendable & Sequence<Date>
Returns a sequence of Date
s, calculated by adding a scaled amount of Calendar.Component
s to a starting Date
. If a range is supplied, the sequence terminates if the next result is not contained in the range. The starting point does not need to be contained in the range, but if the first result is outside of the range then the result will be an empty sequence.
func dates(byMatching: DateComponents, startingAt: Date, in: Range<Date>?, matchingPolicy: Calendar.MatchingPolicy, repeatedTimePolicy: Calendar.RepeatedTimePolicy, direction: Calendar.SearchDirection) -> some Sendable & Sequence<Date>
Computes the dates which match (or most closely match) a given set of components, returned as a Sequence
.
func encode(to: any Encoder) throws
func enumerateDates(startingAfter: Date, matching: DateComponents, matchingPolicy: Calendar.MatchingPolicy, repeatedTimePolicy: Calendar.RepeatedTimePolicy, direction: Calendar.SearchDirection, using: (Date?, Bool, inout Bool) -> Void)
Computes the dates which match (or most closely match) a given set of components, and calls the closure once for each of them, until the enumeration is stopped.
func hash(into: inout Hasher)
func isDate(Date, equalTo: Date, toGranularity: Calendar.Component) -> Bool
Compares the given dates down to the given component, reporting them equal if they are the same in the given component and all larger components.
func isDate(Date, inSameDayAs: Date) -> Bool
Returns true
if the given date is within the same day as another date, as defined by the calendar and calendar’s locale.
func isDateInToday(Date) -> Bool
Returns true
if the given date is within today, as defined by the calendar and calendar’s locale.
func isDateInTomorrow(Date) -> Bool
Returns true
if the given date is within tomorrow, as defined by the calendar and calendar’s locale.
func isDateInWeekend(Date) -> Bool
Returns true
if the given date is within a weekend period, as defined by the calendar and calendar’s locale.
func isDateInYesterday(Date) -> Bool
Returns true
if the given date is within yesterday, as defined by the calendar and calendar’s locale.
func maximumRange(of: Calendar.Component) -> Range<Int>?
The maximum range limits of the values that a given component can take on in the receive
func minimumRange(of: Calendar.Component) -> Range<Int>?
Returns the minimum range limits of the values that a given component can take on in the receiver.
func nextDate(after: Date, matching: DateComponents, matchingPolicy: Calendar.MatchingPolicy, repeatedTimePolicy: Calendar.RepeatedTimePolicy, direction: Calendar.SearchDirection) -> Date?
Computes the next date which matches (or most closely matches) a given set of components.
func nextWeekend(startingAfter: Date, direction: Calendar.SearchDirection) -> DateInterval?
Returns a DateInterval
of the next weekend, which starts strictly after the given date.
func nextWeekend(startingAfter: Date, start: inout Date, interval: inout TimeInterval, direction: Calendar.SearchDirection) -> Bool
Returns the range of the next weekend via two inout parameters. The weekend starts strictly after the given date.
func ordinality(of: Calendar.Component, in: Calendar.Component, for: Date) -> Int?
Returns, for a given absolute time, the ordinal number of a smaller calendar component (such as a day) within a specified larger calendar component (such as a week).
func range(of: Calendar.Component, in: Calendar.Component, for: Date) -> Range<Int>?
Returns the range of absolute time values that a smaller calendar component (such as a day) can take on in a larger calendar component (such as a month) that includes a specified absolute time.
func startOfDay(for: Date) -> Date
Returns the first moment of a given Date, as a Date.