How do I parse the string "29 February" into a date structure

function clean_date_string(s,DefaultYear=2020)
    format = Dates.DateFormat("d U Y")
    date = Date(2000,1,1)
    try
        date = parse(Date,s * " 2000",format) + Dates.Year(DefaultYear - 2000)
    catch
        println("Error: in function clean_date_string")
        println("Error: Unable to parse <$s>")
        flush(stdout)
        exit(0)
    end
    return Dates.format(date,"YYYY-mm-dd")
end

I end up with this solution which allows the input string “29 February”

2 Likes