mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-08 14:03:23 +00:00
@@ -131,9 +131,10 @@
|
||||
=========== ================================================================================= ==============================================
|
||||
|
||||
Other strings can be inserted by putting them in `''`. For example
|
||||
`hh'->'mm` will give `01->56`. The following characters can be
|
||||
inserted without quoting them: `:` `-` `(` `)` `/` `[` `]`
|
||||
`,`. A literal `'` can be specified with `''`.
|
||||
`hh'->'mm` will give `01->56`. In addition to spaces,
|
||||
the following characters can be inserted without quoting them:
|
||||
`:` `-` `,` `.` `(` `)` `/` `[` `]`.
|
||||
A literal `'` can be specified with `''`.
|
||||
|
||||
However you don't need to necessarily separate format patterns, as an
|
||||
unambiguous format string like `yyyyMMddhhmmss` is also valid (although
|
||||
|
||||
@@ -71,7 +71,7 @@ template runTimezoneTests() =
|
||||
"2006-01-12T22:04:05Z", 11)
|
||||
# RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
|
||||
parseTest("2006-01-12T15:04:05.999999999Z-07:00",
|
||||
"yyyy-MM-dd'T'HH:mm:ss'.999999999Z'zzz", "2006-01-12T22:04:05Z", 11)
|
||||
"yyyy-MM-dd'T'HH:mm:ss.'999999999Z'zzz", "2006-01-12T22:04:05Z", 11)
|
||||
for tzFormat in ["z", "zz", "zzz"]:
|
||||
# formatting timezone as 'Z' for UTC
|
||||
parseTest("2001-01-12T22:04:05Z", "yyyy-MM-dd'T'HH:mm:ss" & tzFormat,
|
||||
@@ -770,3 +770,15 @@ block: # ttimes
|
||||
proc test(): DateTime {.gcsafe.} =
|
||||
result = "1970".parse("yyyy")
|
||||
doAssert test().year == 1970
|
||||
|
||||
block: # test FormatLiterals
|
||||
# since #23861
|
||||
block:
|
||||
let dt = dateTime(2024, mJul, 21, 17, 01, 02, 123_321_123, utc())
|
||||
check dt.format("ss.fff") == "02.123"
|
||||
check dt.format("fff.ffffff") == "123.123321"
|
||||
block:
|
||||
let dt = parse("2024.07.21", "yyyy.MM.dd")
|
||||
check dt.year == 2024
|
||||
check dt.month == mJul
|
||||
check dt.monthday == 21
|
||||
|
||||
Reference in New Issue
Block a user