Skip to content

Base.Dates.ISO1123Format incorrect #27811

@janssen

Description

@janssen

Looking at Base.Dates, I see an exported DateFormat, RFC1123Format, which is invalid. It's missing the timezone field, which is present in, for example, HTTP response headers, and is explicitly part of the RFC 822 format referred by RFC 1123. This leads to errors, like this one:

julia> DateTime("Wed, 27 Jun 2018 00:19:54 GMT", RFC1123Format)
ERROR: ArgumentError: Found extra characters at the end of date time string
Stacktrace:
 [1] macro expansion at ./dates/parse.jl:103 [inlined]
 [2] tryparsenext_core(::String, ::Int64, ::Int64, ::DateFormat{Symbol("e, dd u yyyy HH:MM:SS"),Tuple{Base.Dates.DatePart{'e'},Base.Dates.Delim{String,2},Base.Dates.DatePart{'d'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'u'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'y'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'H'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'M'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'S'}}}, ::Bool) at ./dates/parse.jl:39
 [3] macro expansion at ./dates/parse.jl:153 [inlined]
 [4] tryparsenext_internal(::Type{DateTime}, ::String, ::Int64, ::Int64, ::DateFormat{Symbol("e, dd u yyyy HH:MM:SS"),Tuple{Base.Dates.DatePart{'e'},Base.Dates.Delim{String,2},Base.Dates.DatePart{'d'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'u'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'y'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'H'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'M'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'S'}}}, ::Bool) at ./dates/parse.jl:129
 [5] parse(::Type{DateTime}, ::String, ::DateFormat{Symbol("e, dd u yyyy HH:MM:SS"),Tuple{Base.Dates.DatePart{'e'},Base.Dates.Delim{String,2},Base.Dates.DatePart{'d'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'u'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'y'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'H'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'M'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'S'}}}) at ./dates/parse.jl:270
 [6] DateTime(::String, ::DateFormat{Symbol("e, dd u yyyy HH:MM:SS"),Tuple{Base.Dates.DatePart{'e'},Base.Dates.Delim{String,2},Base.Dates.DatePart{'d'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'u'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'y'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'H'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'M'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'S'}}}) at ./dates/io.jl:422

There would seem to be two reasonable options: either implement timezone support in Dates, or remove the RFC1123Format constant so that it doesn't mislead others as it misled me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    datesDates, times, and the Dates stdlib module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions