I miss some function which would tell me if year is leap. Did I miss something or it is really missing?
👀 1
i
ilya.gorbunov
10/25/2020, 10:38 PM
There's no direct way so far, but you can construct the dates Mar 1 and Feb 1 of that year, find the number of days between them and decide whether the year is leap based on that number.
What is your use case, though?
j
Jan Skrasek
10/26/2020, 5:55 AM
I have a date and I want to know number of days in that month. date.month.length() requires to pass that boolean.
i
ilya.gorbunov
10/26/2020, 11:40 AM
In that case you can construct the first day of that month, add one month to it, and then find the number of days between these two dates:
Copy code
val d1 = LocalDate(date.year, date.month, 1)
val d2 = d1.plus(1, DateTimeUnit.MONTH)
val days = d1.until(d2, DateTimeUnit.DAY)
j
Jan Skrasek
10/26/2020, 12:02 PM
Thanks, I did it somehow similarly (also restructured the code to not need it directly this way).
But the main issue here IMO the current API which asks for something I don't have.
Either I'd like
a) to not provide the isYearLeap. (