Alternatively, you could remove the use of Symbols entirely by making use of the built-in Date tools:
julia> using Dates
julia> function dayp(interval::DatePeriod = Day(1))
return Dates.value(Day(interval))
end
dayp (generic function with 2 methods)
julia> dayp(Day(1))
1
julia> dayp(Week(1))
7
julia> dayp(Week(3))
21
This avoids the issue you’re dealing with and avoids needing to hard-code the number of days in every possible number of weeks by hand.
You can even do:
julia> const day = Day(1)
1 day
and now the implicit multiplication of 1day
will actually just work:
julia> 1day
1 day
julia> 2day
2 days
julia> 3day
3 days
julia> dayp(3day)
3