codewinsdotcom/PostgresClientKit

PostgresDate to Date

AMBIENTE1 opened this issue · 2 comments

Hello pitfield,
please what is the correct solution if I want to store column type date() to Date?

for row in cursor {
             let columns = try row.get().columns
              let xrow_date = try columns[0].date()
       
               saveData( ucetnidatum: xrow_date )     error: Cannot convert value of type 'PostgresDate' to expected argument type 'Date'
            }

func saveDate(ucetnidatum: Date) {

}

I need to store the date type value in the Core data.

Call date(in:) on the value returned by PostgresValue.date(). For example:

let xrow_date = try columns[0].date() // xrow_date is of type PostgresDate
let d = xrow_date.date(in: utcTimeZone) // d is a Foundation Date

Yes., Thank you! :)