diff --git a/fiber_orm.nimble b/fiber_orm.nimble index 3fadd3a..ab2ca19 100644 --- a/fiber_orm.nimble +++ b/fiber_orm.nimble @@ -1,6 +1,6 @@ # Package -version = "0.3.1" +version = "0.3.2" author = "Jonathan Bernard" description = "Lightweight Postgres ORM for Nim." license = "GPL-3.0" diff --git a/src/fiber_orm/util.nim b/src/fiber_orm/util.nim index d4b5771..c563a89 100644 --- a/src/fiber_orm/util.nim +++ b/src/fiber_orm/util.nim @@ -90,11 +90,14 @@ proc parsePGDatetime*(val: string): DateTime = if match.isSome: let c = match.get.captures try: - let corrected = c[0] & alignLeft(c[1], 3, '0') & c[2] - return corrected.parse(PG_TIMESTAMP_FORMATS[1]) + if c.toSeq.len == 2: + let corrected = c[0] & alignLeft(c[1], 3, '0') + return corrected.parse(PG_TIMESTAMP_FORMATS[2]) + else: + let corrected = c[0] & alignLeft(c[1], 3, '0') & c[2] + return corrected.parse(PG_TIMESTAMP_FORMATS[3]) except: - errStr &= "\n\t" & PG_TIMESTAMP_FORMATS[1] & - " after padding out milliseconds to full 3-digits" + errStr &= "\n\t" & getCurrentExceptionMsg() raise newException(ValueError, "Cannot parse PG date. Tried:" & errStr)