summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorJake Leahy <jake@leahy.dev>2023-02-21 22:04:27 +1100
committerGitHub <noreply@github.com>2023-02-21 12:04:27 +0100
commit6d423f1856d086ea9e6b0995e3e5f831f4f89aa6 (patch)
tree777184bd2cd93e16efb03124fde73aed8ab19efb /lib/pure
parente54d3cc418f9eab750563aa771070374d559fe57 (diff)
downloadNim-6d423f1856d086ea9e6b0995e3e5f831f4f89aa6.tar.gz
Make `Time` work with `std/strformat` (#21409)
* Add test case

* Remove formatValue template for `Time`

It didn't handle empty specifier correctly which caused it to be blank with strformat
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/times.nim6
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/pure/times.nim b/lib/pure/times.nim
index 3327b2510..70af466d9 100644
--- a/lib/pure/times.nim
+++ b/lib/pure/times.nim
@@ -2109,7 +2109,7 @@ proc format*(dt: DateTime, f: static[string]): string {.raises: [].} =
   const f2 = initTimeFormat(f)
   result = dt.format(f2)
 
-proc formatValue*(result: var string; value: DateTime, specifier: string) =
+proc formatValue*(result: var string; value: DateTime | Time, specifier: string) =
   ## adapter for strformat. Not intended to be called directly.
   result.add format(value,
     if specifier.len == 0: "yyyy-MM-dd'T'HH:mm:sszzz" else: specifier)
@@ -2133,10 +2133,6 @@ proc format*(time: Time, f: static[string], zone: Timezone = local()): string
   const f2 = initTimeFormat(f)
   result = time.inZone(zone).format(f2)
 
-template formatValue*(result: var string; value: Time, specifier: string) =
-  ## adapter for `strformat`. Not intended to be called directly.
-  result.add format(value, specifier)
-
 proc parse*(input: string, f: TimeFormat, zone: Timezone = local(),
     loc: DateTimeLocale = DefaultLocale): DateTime
     {.raises: [TimeParseError, Defect].} =