If I should propose a solution for Dates.jl, I’d go for a typestable definition
function firstdayofISOyear(x)
firstday = firstdayofweek(firstdayofyear(x))
week(firstday) == 1 ? firstday : firstday + Day(7)
end
firstdayofISOyear(x::Integer) = firstdayofISOyear(Date(Year(x)))
firstdayofISOweek(year, week::Integer) = firstdayofISOyear(year) + Day(7(week - 1))
julia> firstdayofISOyear(2025)
2024-12-30
julia> firstdayofISOyear(today())
2025-03-31
julia> firstdayofISOyear(now())
2025-03-31T00:00:00
julia> firstdayofISOyear(2005)
2005-01-03
julia> firstdayofISOweek(2005, 43)
2005-10-24
julia> firstdayofISOweek(now(), 43)
2025-10-20T00:00:00
Any opinions to this version?