Strformat symbol binding (#10927)
This commit is contained in:
parent
f2f9386101
commit
3a5a0f6d46
6 changed files with 186 additions and 138 deletions
|
|
@ -2330,6 +2330,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) =
|
||||
## adapter for strformat. Not intended to be called directly.
|
||||
result.add format(value, specifier)
|
||||
|
||||
proc format*(time: Time, f: string, zone: Timezone = local()): string
|
||||
{.raises: [TimeFormatParseError].} =
|
||||
## Shorthand for constructing a ``TimeFormat`` and using it to format
|
||||
|
|
@ -2349,6 +2353,10 @@ 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()): DateTime
|
||||
{.raises: [TimeParseError, Defect].} =
|
||||
## Parses ``input`` as a ``DateTime`` using the format specified by ``f``.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue