-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Open
Enhancement
Copy link
Labels
datesDates, times, and the Dates stdlib moduleDates, times, and the Dates stdlib modulefeatureIndicates new feature / enhancement requestsIndicates new feature / enhancement requests
Description
AFAIK there's currently no function to calculate the starting date of a week for a given year. I've stumbled across https://discourse.julialang.org/t/determine-date-range-given-year-and-week-number/93878/11 that provides a solution.
Based on that discussion, I propose the following addition to Dates:
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))
# or alternatively add a two-argument method to `firstdayofweek()`
firstdayofweek(year, week::Integer) = firstdayofISOyear(year) + Day(7(week - 1))
would be interested in knowing what you think.
Metadata
Metadata
Assignees
Labels
datesDates, times, and the Dates stdlib moduleDates, times, and the Dates stdlib modulefeatureIndicates new feature / enhancement requestsIndicates new feature / enhancement requests