diff options
author | Julien Dessaux | 2021-10-22 17:59:44 +0200 |
---|---|---|
committer | Julien Dessaux | 2021-10-25 15:22:24 +0200 |
commit | ad9b9c0f7bd4d95ddc54462970d33d92bab9392c (patch) | |
tree | b8d130d728fda49c64b6e021da31afb2418b78a0 /src/dbUtils.nim | |
parent | Initial import (diff) | |
download | short-ad9b9c0f7bd4d95ddc54462970d33d92bab9392c.tar.gz short-ad9b9c0f7bd4d95ddc54462970d33d92bab9392c.tar.bz2 short-ad9b9c0f7bd4d95ddc54462970d33d92bab9392c.zip |
Added a functionning url shortening service
Diffstat (limited to 'src/dbUtils.nim')
-rw-r--r-- | src/dbUtils.nim | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/dbUtils.nim b/src/dbUtils.nim new file mode 100644 index 0000000..bdbcf14 --- /dev/null +++ b/src/dbUtils.nim @@ -0,0 +1,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 |