Remove hidden dependency on timeutils (private repo).
This commit is contained in:
parent
bd5d8c98b8
commit
4e0a173c76
@ -1,6 +1,6 @@
|
|||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
author = "Jonathan Bernard"
|
author = "Jonathan Bernard"
|
||||||
description = "Lightweight Postgres ORM for Nim."
|
description = "Lightweight Postgres ORM for Nim."
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
|
@ -83,6 +83,7 @@
|
|||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
## # db.nim
|
## # db.nim
|
||||||
|
## import std/db_postgres
|
||||||
## import fiber_orm
|
## import fiber_orm
|
||||||
## import ./models.nim
|
## import ./models.nim
|
||||||
##
|
##
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# Copyright 2019 Jonathan Bernard <jonathan@jdbernard.com>
|
# Copyright 2019 Jonathan Bernard <jonathan@jdbernard.com>
|
||||||
|
|
||||||
## Utility methods used internally by Fiber ORM.
|
## Utility methods used internally by Fiber ORM.
|
||||||
import json, macros, options, sequtils, strutils, times, timeutils, unicode,
|
import json, macros, options, sequtils, strutils, times, unicode,
|
||||||
uuids
|
uuids
|
||||||
|
|
||||||
import nre except toSeq
|
import nre except toSeq
|
||||||
@ -18,6 +18,26 @@ type
|
|||||||
placeholders*: seq[string]
|
placeholders*: seq[string]
|
||||||
values*: seq[string]
|
values*: seq[string]
|
||||||
|
|
||||||
|
const ISO_8601_FORMATS = @[
|
||||||
|
"yyyy-MM-dd'T'HH:mm:ssz",
|
||||||
|
"yyyy-MM-dd'T'HH:mm:sszzz",
|
||||||
|
"yyyy-MM-dd'T'HH:mm:ss'.'fffzzz",
|
||||||
|
"yyyy-MM-dd HH:mm:ssz",
|
||||||
|
"yyyy-MM-dd HH:mm:sszzz",
|
||||||
|
"yyyy-MM-dd HH:mm:ss'.'fffzzz"
|
||||||
|
]
|
||||||
|
|
||||||
|
proc parseIso8601(val: string): DateTime =
|
||||||
|
var errString = ""
|
||||||
|
for df in ISO_8601_FORMATS:
|
||||||
|
try: return val.parse(df)
|
||||||
|
except: errString &= "\n" & getCurrentExceptionMsg()
|
||||||
|
raise newException(Exception, "Could not parse date. Tried:" & errString)
|
||||||
|
|
||||||
|
proc formatIso8601(d: DateTime): string =
|
||||||
|
return d.format(ISO_8601_FORMATS[2])
|
||||||
|
|
||||||
|
|
||||||
# TODO: more complete implementation
|
# TODO: more complete implementation
|
||||||
# see https://github.com/blakeembrey/pluralize
|
# see https://github.com/blakeembrey/pluralize
|
||||||
proc pluralize*(name: string): string =
|
proc pluralize*(name: string): string =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user