PostgresDate
public struct PostgresDate:
PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
Represents a Postgres DATE value, which consists of the following components:
- year
- month
- day
For example, 2019-03-14.
-
Creates a
PostgresDatefrom components.For example, to represent
2019-03-14:let date = PostgresDate(year: 2019, month: 3, day: 14)Declaration
Swift
public init?(year: Int, month: Int, day: Int)Parameters
yearthe year value
monththe month value (1 for January, 2 for February, and so on)
daythe day value
-
Creates a
PostgresDateby interpreting aDatein a specified time zone to obtain the year, month, and day components, and discarding the hour, minute, second, and fractional second components.(Foundation
Dateinstances represent moments in time, not (year, month, day) tuples.)Declaration
Swift
public init(date: Date, in timeZone: TimeZone)Parameters
datethe moment in time
timeZonethe time zone in which to interpret that moment
-
Creates a
PostgresDatefrom a string.The string must conform to the date format pattern
yyyy-MM-dd. For example,2019-03-14.Declaration
Swift
public init?(_ string: String)Parameters
stringthe string
-
A
DateComponentsvalue for thisPostgresDate.The returned value has the following components set:
yearmonthday
Declaration
Swift
public var dateComponents: DateComponents { get } -
Creates a
Dateby interpreting thisPostgresDatein a specified time zone, setting the hour, minute, second, and fractional second components to 0.(Foundation
Dateinstances represent moments in time, not (year, month, day) tuples.)Declaration
Swift
public func date(in timeZone: TimeZone) -> DateParameters
timeZonethe time zone
Return Value
the moment in time
-
A
PostgresValuefor thisPostgresDate.Declaration
Swift
public var postgresValue: PostgresValue { get }
-
True if
lhs.postgresValue == rhs.postgresValue.Declaration
Swift
public static func == (lhs: PostgresDate, rhs: PostgresDate) -> Bool
-
Declaration
Swift
public init(from decoder: Decoder) throws
-
A string representation of this
PostgresDate.Equivalent to
String(describing: postgresValue).Declaration
Swift
public var description: String { get }