-
Notifications
You must be signed in to change notification settings - Fork 102
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
Simplify LocalDate(Time) constructor parameter names #84
Comments
These parameters are named this way, so that one can get back the values passed to the constructor from the same-named properties of the constructed object. |
That property Kotlin tries to be pragmatic for the majority of use cases. The vast majority when working with dates is using the day of month. Everybody and their mother knows what a day refers to when dealing with a year/month/day date (+ time). So, if Kotlin is a language optimized for general application development and the majority of use cases, |
Btw, the compiler makes things more confusing. I've provided year, month and day all as
I also think that the names being more natural overweighs the benefit of having |
You make a good point about Regarding
So, it makes sense for In your example (which, I assume, is simplified, but nonetheless), WDYT? |
I believe that numbering months from zero is an abomination and should not be considered a normal practice that we take into account when naming the corresponding parameter/property. |
What is an abomination is using the |
Here's the proposal:
|
`monthNumber` is still called that in the formatting facilities to distinguish `monthNumber` from `monthName`, and also in `DateTimeComponents` because `monthNumber` can contain out-of-bounds data and is useful even aside from being a view of `Month`. Fixes #84 Blocked by an IDE bug: <https://youtrack.jetbrains.com/issue/KTIJ-29647/ReplaceWith-of-properties-just-erases-code>
`monthNumber` is still called that in the formatting facilities to distinguish `monthNumber` from `monthName`, and also in `DateTimeComponents` because `monthNumber` can contain out-of-bounds data and is useful even aside from being a view of `Month`. Fixes #84 Blocked by an IDE bug: <https://youtrack.jetbrains.com/issue/KTIJ-29647/ReplaceWith-of-properties-just-erases-code>
`monthNumber` is still called that in the formatting facilities to distinguish `monthNumber` from `monthName`, and also in `DateTimeComponents` because `monthNumber` can contain out-of-bounds data and is useful even aside from being a view of `Month`. Fixes #84 Blocked by an IDE bug: <https://youtrack.jetbrains.com/issue/KTIJ-29647/ReplaceWith-of-properties-just-erases-code>
`monthNumber` is still called that in the formatting facilities to distinguish `monthNumber` from `monthName`, and also in `DateTimeComponents` because `monthNumber` can contain out-of-bounds data and is useful even aside from being a view of `Month`. Fixes #84 Blocked by an IDE bug: <https://youtrack.jetbrains.com/issue/KTIJ-29647/ReplaceWith-of-properties-just-erases-code>
`monthNumber` is still called that in the formatting facilities to distinguish `monthNumber` from `monthName`, and also in `DateTimeComponents` because `monthNumber` can contain out-of-bounds data and is useful even aside from being a view of `Month`. Fixes #84
The parameter names are very weird for day-to-day use:
I don't care that
month
is a number. That's what we have a type system for.OfMonth
forday
is also redundant as that's obvious from the context.kotlinx-datetime/core/common/src/LocalDateTime.kt
Line 50 in 3af71d2
The text was updated successfully, but these errors were encountered: