Time
public struct Time : Equatable, Comparable, Hashable
Date-time defined by week number (since first week of 2001), day of week (0-6), and time of day (in seconds).
-
Initializes a date-time value using a day number instead of week and day of week.
Declaration
Swift
public init(dayNumber: Int, timeOfDay: TimeOfDay = 0)
-
Initializes a date-time value using a day number instead of week and day of week, and with hours, and optionally minutes and/or seconds instead of time of day.
Declaration
Swift
public init(dayNumber: Int, hours: Double, minutes: Double = 0, seconds: TimeInterval = 0)
-
Week number, since first week of 2001. (Negative values indicate time before the reference week.)
Declaration
Swift
public var week: Week
-
Day of the week number, between Sunday (0) and Saturday (6).
Declaration
Swift
public var dayOfWeek: DayOfWeek
-
Time of day in seconds passed since midnight. Maximum accepted value is the next midnight (24*60*60=86400), indicating the end of the day (conceptually different, although equal in value with the beginning of the next day).
Declaration
Swift
public var timeOfDay: TimeOfDay
-
Zero-based day number starting on the reference date (12-31-2000).
Declaration
Swift
public var dayNumber: Int { get set }
-
Time of day expressed in hours, as a decimal number between 0 and 24.
Declaration
Swift
public var hoursOfDay: Double { get set }
-
Returns the date-time indicating the start of the day (midnight).
Declaration
Swift
public var dayStart: Time { get }
-
Returns the date-time indicating the finish of the day (next midnight).
Declaration
Swift
public var dayFinish: Time { get }
-
Returns the date-time indicating the start of the week (Sunday, midnight).
Declaration
Swift
public var weekStart: Time { get }
-
Returns the date-time indicating the finish of the week (next Sunday, midnight).
Declaration
Swift
public var weekFinish: Time { get }
-
Returns the value resulting by adding a specified duration (in seconds) to the date-time.
Declaration
Swift
public func adding(duration: TimeInterval) -> Time
-
Returns the value resulting by adding a specified number of days to the date-time.
Declaration
Swift
public func adding(days: Int) -> Time
-
Returns the value resulting by adding a specified number of weeks to the date-time.
Declaration
Swift
public func adding(weeks: Int) -> Time
-
Returns the value resulting by adding a specified number of hours to the date-time.
Declaration
Swift
public func adding(hours: Double) -> Time
-
Returns the value resulting by adding a specified number of minutes to the date-time.
Declaration
Swift
public func adding(minutes: Double) -> Time
-
Returns the value resulting by adding a specified number of seconds to the date-time.
Declaration
Swift
public func adding(seconds: Double) -> Time
-
Returns the value resulting by adding a specified duration (in a specific time unit) to the date-time.
Declaration
Swift
public func adding(duration: Double, in unit: TimeUnit) -> Time
-
Returns the same date-time value, avoiding next midnight indicator value (which cannot be a start time).
Declaration
Swift
public var asStart: Time { get }
-
Returns the same date-time value, avoiding midnight indicator value (which cannot be a finish time).
Declaration
Swift
public var asFinish: Time { get }
-
Indicates whether the date-time value has time of day defined as midnight.
Declaration
Swift
public var isDayStart: Bool { get }
-
Indicates whether the date-time value has time of day defined as next midnight.
Declaration
Swift
public var isDayFinish: Bool { get }
-
Minimum accepted past date-time value (a date-time before year 80,000 BCE).
Declaration
Swift
public static let min: Time
-
Maximum accepted future date-time value (a date-time after year 80,000).
Declaration
Swift
public static let max: Time
-
Reference week start date-time (Sunday, 12-31-2000 = 01-01-2001 - 1d).
Declaration
Swift
public static let reference: Time
-
Reference month start (01-01-2001).
Declaration
Swift
public static let referenceMonthStart: Time
-
Checks whether two date-time values are referring the same moment. (Note that the end of a day is equal to the beginning of the next day.)
Declaration
Swift
public static func == (lhs: Time, rhs: Time) -> Bool
-
Compares two date-time values. (Note that the end of a day is not different than the beginning of the next day.)
Declaration
Swift
public static func < (lhs: Time, rhs: Time) -> Bool
-
Computes the week value (considering the reference date) associated to the specified day number.
Declaration
Swift
public static func week(dayNumber: Int) -> Week
-
Computes the day of week value (number between 0 and 6, representing Sunday and, respectively, Saturday) associated to the specified day number.
Declaration
Swift
public static func dayOfWeek(dayNumber: Int) -> Week
-
Computes the time of day value (in seconds since midnight) associated to the specified hours and/or minutes and seconds.
Declaration
Swift
public static func timeOfDay(hours: Double, minutes: Double = 0, seconds: Double = 0) -> TimeOfDay
-
Computes the hours of day (decimal number between 0 and 24) associated to the specified time of day value.
Declaration
Swift
public static func hoursOfDay(timeOfDay: TimeOfDay) -> Double
-
Returns the current date-time considering the local time zone.
Declaration
Swift
public static var current: Time { get }
-
Initializes a date-time value based on current date and time, optionally considering the specified time zone (by default the local time zone is used).
Declaration
Swift
public init(for timeZone: TimeZone? = nil)
-
Initializes a date-time value based on the specified Date.
Declaration
Swift
public init(_ date: Date)
-
Initializes a date-time value based on specified components.
Declaration
Swift
public init(year: Int, month: Int = 1, day: Int = 1, hour: Int = 0, minute: Int = 0, second: Int = 0)
-
Undocumented
Declaration
Swift
public var year: Int { get }
-
Undocumented
Declaration
Swift
public var month: Int { get }
-
Undocumented
Declaration
Swift
public var day: Int { get }
-
Undocumented
Declaration
Swift
public var hour: Int { get }
-
Undocumented
Declaration
Swift
public var minute: Int { get }
-
Undocumented
Declaration
Swift
public var second: Int { get }
-
Undocumented
Declaration
Swift
public func component(_ type: Calendar.Component) -> Int
-
Returns the date-time indicating the start of the month (day 1, midnight).
Declaration
Swift
public var monthStart: Time { get }
-
Returns the date-time indicating the start of the year (day 1 of month 1, midnight).
Declaration
Swift
public var yearStart: Time { get }
-
Returns the value resulting by adding a specified number of months to the date-time.
Declaration
Swift
public func adding(months: MonthInterval) -> Time
-
Returns the value resulting by adding a specified number of years to the date-time.
Declaration
Swift
public func adding(years: Int) -> Time
-
Returns the value resulting by adding a specified duration (in a specific calendar time unit) to the date-time.
Declaration
Swift
public func adding(duration: Int, in unit: CalendarTimeUnit) -> Time
-
Reference calendar used for converting date-time values from and to Date type, including internally when you initialize date-time values by specifying date components, when you read components of a date-time value, when you use DateFormatter to convert a date-time value from or to String type, and when you add specific months or years to existing date-time values.
Declaration
Swift
public static let calendar: Calendar