chrono
chrono copied to clipboard
convenience functions to create NaiveDates
These functions are to reduce the number of unwraps needed when creating NaiveDates
I am not super convinced of the usefulness of all these methods. My reason is that there are all kinds of operations someone may want to do on dates. Where do you draw the line?
end_month and end_year seem useful because they are non-trivial. You should get the current year/month, add 1 (this can cause a panic on overflow), and get the preceding day.
But then you would also want start_month and start_year for symmetry, which don't feel valuable enough for me.
Would similar methods on NaiveDateTime or DateTime make sense? Would the end of a month be at the last second? Or the last nanoseond? Or maybe even leap-second? Strictly speaking, the end is the same as the start of the next day, at 0:00:00. But than the date would be different from the one returned by NaiveDate::end_month.
Closing. I would be interested to have a method to easily create a NaiveDate at the end of a month.