-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting days in Month #184
Comments
It's dependent on the year, due to leap days, so something like this is needed: fun monthDays(year: Int, month: Month): Int {
val start = LocalDate(year, month, 1)
val end = start.plus(DateTimeUnit.MONTH)
return start.until(end, DateTimeUnit.DAY)
} Literally, "how many days between the start of this month and the next month". |
Thanks for the suggestion. I think having this method implemented in the library would prove useful to quite a lot of people. |
Perhaps if we get that |
There's an upside to the solution provided above: it uses the conceptually simple By not providing wrappers around |
IMO, getting the length of a month by creating two dates and subtracting them is a more contrived way than to query it directly from some calendar info provider. So, these functions are conceptually not wrappers around |
If we did have a calendar-info-provider thing, then sure. Currently, however, the My point is, providing just something like Implementing a more general way to query calendar info would be a clear solution for this, I agree. So would be something like |
Is there currently any way of getting the number of total days in a month?
The text was updated successfully, but these errors were encountered: