jackc / pgtype

MIT License
300 stars 111 forks source link

Support postgres dates with "BC" #192

Closed jozolam closed 1 year ago

jozolam commented 1 year ago

Postgre is adding the suffix " BC" to dates that occurred "Before Christ". I was unable to parse such values and got parsing time "0001-01-01 BC": extra text: " BC" error. This is caused by the usage of time.ParseInLocation which (for the used layout) does not expect " BC" suffix.

dundee commented 1 year ago

Btw similar logic is implemented here: https://github.com/lib/pq/blob/d5affd5073b06f745459768de35356df2e5fd91d/encode.go#L397