Julia: Dates.parse(::AbstractString, ::DateFormat) removed without deprecation

Created on 3 Mar 2017  路  3Comments  路  Source: JuliaLang/julia

Julia 0.5 had a Dates.parse function which could parse a string into an Array{Period}. The function was useful for parsing DateTimes which needed modification before constructing a DateTime object.

For example on Julia 0.5:

julia> df = Dates.DateFormat("yyyy-mm-dd HH:MM");

julia> DateTime("2016-03-03 24:00", df)
ERROR: ArgumentError: Hour: 24 out of range (0:23)
 in DateTime(::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64) at ./dates/types.jl:149
 in DateTime(::Base.Dates.Year, ::Base.Dates.Month, ::Base.Dates.Day, ::Base.Dates.Hour, ::Base.Dates.Minute) at ./dates/types.jl:172
 in DateTime(::String, ::Base.Dates.DateFormat) at ./dates/io.jl:268

julia> Dates.parse("2016-03-03 24:00", df)
5-element Array{Base.Dates.Period,1}:
 2016 years
 3 months  
 3 days    
 24 hours  
 0 minutes 

In Julia 0.6

julia> Dates.parse("2016-03-03 24:00", Dates.DateFormat("yyyy-mm-dd HH:MM"))
ERROR: MethodError: no method matching parse(::String, ::DateFormat{Symbol("yyyy-mm-dd HH:MM"),Tuple{Base.Dates.DatePart{'y'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'m'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'d'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'H'},Base.Dates.Delim{Char,1},Base.Dates.DatePart{'M'}}})
Closest candidates are:
  parse(::AbstractString, ::Int64; greedy, raise) at parse.jl:215
  parse(::AbstractString; raise) at parse.jl:230
dates

Most helpful comment

@StefanKarpinski I'm attempting to get a version of this working with 0.6

All 3 comments

Removed by #19545

@shashi, can we add that feature back within the new fast parsing framework? Otherwise it should technically be deprecated, but it seems like making it work would be even better as it's useful.

@StefanKarpinski I'm attempting to get a version of this working with 0.6

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arshpreetsingh picture arshpreetsingh  路  3Comments

TotalVerb picture TotalVerb  路  3Comments

StefanKarpinski picture StefanKarpinski  路  3Comments

dpsanders picture dpsanders  路  3Comments

thofma picture thofma  路  3Comments