LocalDateTime
public struct LocalDateTime
Undocumented
-
The minimum supported LocalDateTime, ‘-999999999-01-01T00:00:00’.
Declaration
Swift
public static var min: LocalDateTime { get }
-
The maximum supported LocalDateTime, ‘+999999999-12-31T23:59:59.999999999’.
Declaration
Swift
public static var max: LocalDateTime { get }
-
Obtains an instance of LocalDateTime from a text string such as ‘2007-12-03T10:15:30.217’.
If the input text and date format are mismatched, returns nil.
Declaration
Swift
public static func parse(_ text: String, clock: Clock) -> LocalDateTime?
Parameters
text
The text to parse.
clock
The Clock instance.
Return Value
The parsed local date-time.
-
Obtains an instance of LocalDateTime from a text string such as ‘2007-12-03T10:15:30.217’.
If the input text and date format are mismatched, returns nil.
Declaration
Swift
static public func parse(_ text: String, timeZone: TimeZone = TimeZone.current) -> LocalDateTime?
Parameters
text
The text to parse.
timeZone
The TimeZone instance.
Return Value
The parsed local date-time.
-
Obtains an instance of LocalDateTime from a text string using a specific formatter.
If the input text and date format are mismatched, returns nil.
Declaration
Swift
public static func parse(_ text: String, formatter: DateFormatter, clock: Clock) -> LocalDateTime?
Parameters
text
The text to parse.
formatter
The formatter to parse.
clock
The Clock instance.
Return Value
The parsed local date-time.
-
Obtains an instance of LocalDateTime from a text string using a specific formatter.
If the input text and date format are mismatched, returns nil.
Declaration
Swift
static public func parse(_ text: String, formatter: DateFormatter, timeZone: TimeZone = TimeZone.current) -> LocalDateTime?
Parameters
text
The text to parse.
formatter
The formatter to parse.
timeZone
The TimeZone instance.
Return Value
The parsed local date-time.
-
The date part.
Declaration
Swift
public var date: LocalDate { get set }
-
The time part.
Declaration
Swift
public var time: LocalTime { get set }
-
Gets the year field.
Declaration
Swift
public var year: Int { get set }
-
Gets the month-of-year field from 1 to 12.
Declaration
Swift
public var month: Int { get set }
-
Gets the day-of-month field.
Declaration
Swift
public var day: Int { get set }
-
Gets the day-of-week field.
Declaration
Swift
public var dayOfWeek: Int { get }
-
Gets the hour-of-day field.
Declaration
Swift
public var hour: Int { get set }
-
Gets the minute-of-hour field.
Declaration
Swift
public var minute: Int { get set }
-
Gets the second-of-minute field.
Declaration
Swift
public var second: Int { get set }
-
Gets the nano-of-second field.
Declaration
Swift
public var nano: Int { get set }
-
Returns the length of the month represented by this date.
Declaration
Swift
public func lengthOfMonth() -> Int
-
Returns the length of the year represented by this date.
Declaration
Swift
public func lengthOfYear() -> Int
-
Checks if the year is a leap year, according to the ISO proleptic calendar system rules.
Declaration
Swift
public func isLeapYear() -> Bool
-
Returns an instance of Date.
Declaration
Swift
public func toDate(clock: Clock) -> Date
-
Returns an instance of Date.
Declaration
Swift
public func toDate(timeZone: TimeZone = TimeZone.current) -> Date
-
Returns a copy of this date-time with the specified field set to a new value.
Declaration
Swift
public func with(component: Component, newValue: Int) -> LocalDateTime
Parameters
component
The field to set in the result.
newValue
The new value of the field in the result.
Return Value
An LocalDateTime based on this with the specified field set.
-
Returns a copy of this LocalDateTime with the year altered.
Declaration
Swift
public func with(year: Int) -> LocalDateTime
Return Value
An LocalDateTime based on this with the specified field set.
-
Returns a copy of this LocalDateTime with the month-of-year altered.
Declaration
Swift
public func with(month: Int) -> LocalDateTime
Return Value
An LocalDateTime based on this with the specified field set.
-
Returns a copy of this LocalDateTime with the day-of-month altered.
Declaration
Swift
public func with(day: Int) -> LocalDateTime
Return Value
An LocalDateTime based on this with the specified field set.
-
Returns a copy of this LocalDateTime with the hour-of-day value altered.
Declaration
Swift
public func with(hour: Int) -> LocalDateTime
Return Value
An LocalDateTime based on this with the specified field set.
-
Returns a copy of this LocalDateTime with the minute-of-hour value altered.
Declaration
Swift
public func with(minute: Int) -> LocalDateTime
Return Value
An LocalDateTime based on this with the specified field set.
-
Returns a copy of this LocalDateTime with the second-of-minute value altered.
Declaration
Swift
public func with(second: Int) -> LocalDateTime
Return Value
An LocalDateTime based on this with the specified field set.
-
Returns a copy of this LocalDateTime with the nano-of-second value altered.
Declaration
Swift
public func with(nano: Int) -> LocalDateTime
Return Value
An LocalDateTime based on this with the specified field set.
-
Returns a copy of this date-time with the specified amount added.
- Results: An LocalDateTime based on this date-time with the specified amount added.
Declaration
Swift
public func plus(component: PlusComponent, newValue: Int) -> LocalDateTime
Parameters
component
The unit of the amount to add.
newValue
The amount of the unit to add to the result.
-
Returns a copy of this LocalDateTime with the specified period in years added.
- Results: An LocalDateTime based on this date-time with the specified amount added.
Declaration
Swift
public func plus(year: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in months added.
- Results: An LocalDateTime based on this date-time with the specified amount added.
Declaration
Swift
public func plus(month: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in weeks added.
- Results: An LocalDateTime based on this date-time with the specified amount added.
Declaration
Swift
public func plus(week: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in days added.
- Results: An LocalDateTime based on this date-time with the specified amount added.
Declaration
Swift
public func plus(day: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in hours added.
- Results: An LocalDateTime based on this date-time with the specified amount added.
Declaration
Swift
public func plus(hour: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in minutes added.
- Results: An LocalDateTime based on this date-time with the specified amount added.
Declaration
Swift
public func plus(minute: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in seconds added.
- Results: An LocalDateTime based on this date-time with the specified amount added.
Declaration
Swift
public func plus(second: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in nanoseconds added.
- Results: An LocalDateTime based on this date-time with the specified amount added.
Declaration
Swift
public func plus(nano: Int) -> LocalDateTime
-
Returns a copy of this date-time with the specified amount subtracted.
- Results: An LocalDateTime based on this date-time with the specified amount subtracted.
Declaration
Swift
public func minus(component: PlusComponent, newValue: Int) -> LocalDateTime
Parameters
component
The unit of the amount to subtract.
newValue
The amount of the unit to subtract to the result.
-
Returns a copy of this LocalDateTime with the specified period in years subtracted.
- Results: An LocalDateTime based on this date-time with the specified amount subtracted.
Declaration
Swift
public func minus(year: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in months subtracted.
- Results: An LocalDateTime based on this date-time with the specified amount subtracted.
Declaration
Swift
public func minus(month: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in weeks subtracted.
- Results: An LocalDateTime based on this date-time with the specified amount subtracted.
Declaration
Swift
public func minus(week: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in days subtracted.
- Results: An LocalDateTime based on this date-time with the specified amount subtracted.
Declaration
Swift
public func minus(day: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in hours subtracted.
- Results: An LocalDateTime based on this date-time with the specified amount subtracted.
Declaration
Swift
public func minus(hour: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in minutes subtracted.
- Results: An LocalDateTime based on this date-time with the specified amount subtracted.
Declaration
Swift
public func minus(minute: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in seconds subtracted.
- Results: An LocalDateTime based on this date-time with the specified amount subtracted.
Declaration
Swift
public func minus(second: Int) -> LocalDateTime
-
Returns a copy of this LocalDateTime with the specified period in nanoseconds subtracted.
- Results: An LocalDateTime based on this date-time with the specified amount subtracted.
Declaration
Swift
public func minus(nano: Int) -> LocalDateTime
-
Gets the range of valid values for the specified field.
Declaration
Swift
public func range(_ component: RangeComponent) -> (Int, Int)
Return Value
The range of valid values for the field.
-
Calculates the period between this date-time and another date-time as a Period.
Declaration
Swift
public func until(endDateTime: LocalDateTime) -> Period
Parameters
endDateTime
The end date-time, exclusive, which is converted to an LocalDateTime.
Return Value
The Period of time between this date-time and the end date-time.
-
Calculates the amount of time until another date-time in terms of the specified unit.
Declaration
Swift
public func until(endDateTime: LocalDateTime, component: UntilComponent) -> Int64
Parameters
endDateTime
The end date-time, exclusive, which is converted to an LocalDateTime.
component
The unit to measure the amount in.
Return Value
The amount of time between this date-time and the end date-time.
-
Formats this date-time using the specified formatter.
Declaration
Swift
public func format(_ formatter: DateFormatter) -> String
Return Value
The formatted date string.
-
LocalDateTime
Declaration
Swift
public static func + (lhs: LocalDateTime, rhs: LocalDateTime) -> LocalDateTime
-
Undocumented
Declaration
Swift
public static func += (lhs: inout LocalDateTime, rhs: LocalDateTime)
-
Undocumented
Declaration
Swift
public static func - (lhs: LocalDateTime, rhs: LocalDateTime) -> LocalDateTime
-
Undocumented
Declaration
Swift
public static func -= (lhs: inout LocalDateTime, rhs: LocalDateTime)
-
LocalDate
Declaration
Swift
public static func + (lhs: LocalDateTime, rhs: LocalDate) -> LocalDateTime
-
Undocumented
Declaration
Swift
public static func += (lhs: inout LocalDateTime, rhs: LocalDate)
-
Undocumented
Declaration
Swift
public static func - (lhs: LocalDateTime, rhs: LocalDate) -> LocalDateTime
-
Undocumented
Declaration
Swift
public static func -= (lhs: inout LocalDateTime, rhs: LocalDate)
-
LocalTime
Declaration
Swift
public static func + (lhs: LocalDateTime, rhs: LocalTime) -> LocalDateTime
-
Undocumented
Declaration
Swift
public static func += (lhs: inout LocalDateTime, rhs: LocalTime)
-
Undocumented
Declaration
Swift
public static func - (lhs: LocalDateTime, rhs: LocalTime) -> LocalDateTime
-
Undocumented
Declaration
Swift
public static func -= (lhs: inout LocalDateTime, rhs: LocalTime)
-
Creates the current date-time from the time-zone.
Declaration
Swift
public init(clock: Clock)
-
Creates the current date-time from the time-zone.
Declaration
Swift
public init(timeZone: TimeZone = TimeZone.current)
-
Creates a local date-time from an instance of Date.
Declaration
Swift
public init(_ date: Date, clock: Clock)
-
Creates a local date-time from an instance of Date.
Declaration
Swift
public init(_ date: Date, timeZone: TimeZone = TimeZone.current)
-
Copies an instance of LocalDateTime.
Declaration
Swift
public init(_ date: LocalDateTime)
-
Creates an instance of LocalDateTime from year, month, day, hour, minute, second and nanosecond.
Declaration
Swift
public init(year: Int, month: Int, day: Int, hour: Int, minute: Int, second: Int = 0, nanoOfSecond: Int = 0)
-
Creates an instance of LocalDateTime using seconds from the epoch of 1970-01-01T00:00:00Z.
Declaration
Swift
public init(epochDay: Int64, nanoOfDay: Int64)
-
Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.
Declaration
Swift
public static func < (lhs: LocalDateTime, rhs: LocalDateTime) -> Bool
-
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
Declaration
Swift
public static func > (lhs: LocalDateTime, rhs: LocalDateTime) -> Bool
-
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
Declaration
Swift
public static func <= (lhs: LocalDateTime, rhs: LocalDateTime) -> Bool
-
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
Declaration
Swift
public static func >= (lhs: LocalDateTime, rhs: LocalDateTime) -> Bool
-
The hash value.
Hash values are not guaranteed to be equal across different executions of your program. Do not save hash values to use during a future execution.
Declaration
Swift
public var hashValue: Int { get }
-
Returns a Boolean value indicating whether two values are equal.
Declaration
Swift
public static func == (lhs: LocalDateTime, rhs: LocalDateTime) -> Bool
-
A textual representation of this instance.
Declaration
Swift
public var description: String { get }
-
A textual representation of this instance, suitable for debugging.
Declaration
Swift
public var debugDescription: String { get }
-
The custom mirror for this instance.
If this type has value semantics, the mirror should be unaffected by subsequent mutations of the instance.
Declaration
Swift
public var customMirror: Mirror { get }
-
Returns the custom playground description for this instance.
If this type has value semantics, the instance returned should be unaffected by subsequent mutations if possible.
Declaration
Swift
public var playgroundDescription: Any { get }
-
Creates a new instance by decoding from the given decoder.
This initializer throws an error if reading from the decoder fails, or if the data read is corrupted or otherwise invalid.
Declaration
Swift
public init(from decoder: Decoder) throws
Parameters
decoder
The decoder to read data from.
-
Encodes this value into the given encoder.
If the value fails to encode anything,
encoder
will encode an empty keyed container in its place.This function throws an error if any values are invalid for the given encoder’s format.
Declaration
Swift
public func encode(to encoder: Encoder) throws
Parameters
encoder
The encoder to write data to.