fixes a critical times.nim bug reported on IRC [backport] (#13216)
This commit is contained in:
parent
b355ef2a72
commit
bdb7c82c6a
2 changed files with 6 additions and 2 deletions
|
|
@ -717,6 +717,9 @@ when isMainModule:
|
||||||
var tm = fromUnix(0)
|
var tm = fromUnix(0)
|
||||||
discard &"{tm}"
|
discard &"{tm}"
|
||||||
|
|
||||||
|
var noww = now()
|
||||||
|
check &"{noww}", $noww
|
||||||
|
|
||||||
# Unicode string tests
|
# Unicode string tests
|
||||||
check &"""{"αβγ"}""", "αβγ"
|
check &"""{"αβγ"}""", "αβγ"
|
||||||
check &"""{"αβγ":>5}""", " αβγ"
|
check &"""{"αβγ":>5}""", " αβγ"
|
||||||
|
|
|
||||||
|
|
@ -2339,9 +2339,10 @@ proc format*(dt: DateTime, f: static[string]): string {.raises: [].} =
|
||||||
const f2 = initTimeFormat(f)
|
const f2 = initTimeFormat(f)
|
||||||
result = dt.format(f2)
|
result = dt.format(f2)
|
||||||
|
|
||||||
template formatValue*(result: var string; value: DateTime, specifier: string) =
|
proc formatValue*(result: var string; value: DateTime, specifier: string) =
|
||||||
## adapter for strformat. Not intended to be called directly.
|
## adapter for strformat. Not intended to be called directly.
|
||||||
result.add format(value, specifier)
|
result.add format(value,
|
||||||
|
if specifier.len == 0: "yyyy-MM-dd'T'HH:mm:sszzz" else: specifier)
|
||||||
|
|
||||||
proc format*(time: Time, f: string, zone: Timezone = local()): string
|
proc format*(time: Time, f: string, zone: Timezone = local()): string
|
||||||
{.raises: [TimeFormatParseError].} =
|
{.raises: [TimeFormatParseError].} =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue