I'm need the chrono::Date
of the first and last date of a week from the current year.
I have two issues,
first I'm unable to get chrono
to parse the week of current year and second I'm unable to get the first/last date of the week. (There are a lot of solutions for other languages here, but not rust)
TLDR: I need a function like this:
fn x(week: isize) -> (Date<Local>, Date<Local>)
with the tuple being (first day of week, last day of week).
If I have understood your question correctly, you can use something like this:
Playground
That is assuming ISO8601 conventions (Monday as the first day and Sunday as the last, and ISO week numbering). It also returns
NaiveDate
instead ofDate<Local>
, which you could obtain using:if needed.