summaryrefslogtreecommitdiff
path: root/src/dbUtils.nim
blob: bdbcf14dc4f61e3f976944e960d8740b54192898 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import std/times
import tiny_sqlite

proc toDbValue*(t: DateTime): DbValue {.raises: [].}=
    DbValue(kind: sqliteText, strVal: $t)

proc fromDbValue*(value: DbValue, T: typedesc[DateTime]): DateTime {.raises: [].}=
  try:
    case value.kind:
      of sqliteText: return times.parse(value.strVal, "yyyy-MM-dd'T'HH:mm:sszzz")
      else: return
  except TimeParseError:
    return