How to parse a string as a Date where the year is a leap one, if the year is not specified in the string?

I have a series of date strings of the form "01 Feb", "02 Feb". I am trying to parse these as Date objects, except it fails as it doesn’t recognize that there were 29 days in Feb this year. Since the year is not specified in the date strings, is there a way to get around this?

Here is what I’m trying:

julia> Date("29 Feb",dateformat"d u")
ERROR: ArgumentError: Day: 29 out of range (1:28)
Stacktrace:
 [1] Date(::Int64, ::Int64, ::Int64) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/Dates/src/types.jl:223
 [2] parse at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/Dates/src/parse.jl:285 [inlined]
 [3] Date(::String, ::DateFormat{Symbol("d u"),Tuple{Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'u'}}}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/Dates/src/io.jl:503
 [4] top-level scope at REPL[16]:1

while this works:

julia> Date("29 Feb 2020",dateformat"d u Y")
2020-02-29

So one way to solve this is to append the year to the strings and then convert. I was wondering if there is a flag that I might provide to the constructor to treat the dates as a leap year without having to alter the strings?

I think I realize what’s going on. By default it sets the year to 0001 which is not a leap year.

julia> Date("28 Feb",dateformat"d u")
0001-02-28

Not sure if there’s an easy way around this?

There is

julia> Dates.parse_components("29 Feb", dateformat"d u")
2-element Array{Any,1}:
 29 days
 2 months
3 Likes