Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes a critical times.nim bug reported on IRC [backport] #13216

Merged
merged 1 commit into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/pure/strformat.nim
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,9 @@ when isMainModule:
var tm = fromUnix(0)
discard &"{tm}"

var noww = now()
check &"{noww}", $noww

# Unicode string tests
check &"""{"αβγ"}""", "αβγ"
check &"""{"αβγ":>5}""", " αβγ"
Expand Down
5 changes: 3 additions & 2 deletions lib/pure/times.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2339,9 +2339,10 @@ proc format*(dt: DateTime, f: static[string]): string {.raises: [].} =
const f2 = initTimeFormat(f)
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.
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
{.raises: [TimeFormatParseError].} =
Expand Down