chrono icon indicating copy to clipboard operation
chrono copied to clipboard

convenience functions to create NaiveDates

Open esheppa opened this issue 3 years ago • 1 comments
trafficstars

These functions are to reduce the number of unwraps needed when creating NaiveDates

esheppa avatar Nov 23 '22 22:11 esheppa

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.

pitdicker avatar Apr 28 '23 09:04 pitdicker

Closing. I would be interested to have a method to easily create a NaiveDate at the end of a month.

pitdicker avatar Apr 10 '24 12:04 pitdicker