aboutsummaryrefslogtreecommitdiff
path: root/src/dbUtils.nim
blob: cfe54cf37c1ae586cf7eb566dc2f2da2c6e0a846 (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