I cannot seem to figure out how to parse a datetime string with am/pm:
using Dates
DateTime("2021-02-01 11:12AM EST", dateformat"y-m-d H:Mp xxx")
gives this error:
ERROR: ArgumentError: Unable to parse date time. Expected directive DatePart(p) at char 16
Stacktrace:
[1] macro expansion at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Dates/src/parse.jl:104 [inlined]
[2] tryparsenext_core(::String, ::Int64, ::Int64, ::DateFormat{Symbol("y-m-d H:Mp xxx"),Tuple{Dates.DatePart{'y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.DatePart{'p'},Dates.Delim{String,4}}}, ::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Dates/src/parse.jl:38
[3] macro expansion at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Dates/src/parse.jl:150 [inlined]
[4] tryparsenext_internal at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Dates/src/parse.jl:125 [inlined]
[5] parse(::Type{DateTime}, ::String, ::DateFormat{Symbol("y-m-d H:Mp xxx"),Tuple{Dates.DatePart{'y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.DatePart{'p'},Dates.Delim{String,4}}}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Dates/src/parse.jl:282
[6] DateTime(::String, ::DateFormat{Symbol("y-m-d H:Mp xxx"),Tuple{Dates.DatePart{'y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.DatePart{'p'},Dates.Delim{String,4}}}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Dates/src/io.jl:482
[7] top-level scope at REPL[4]:1
I tried using ZonedDateTime, replacing the “xxx” with “Z”, but I get the same error. Is this a bug, or am I missing something obvious?