Skip to content
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

Deprecate plus and minus operations taking DateTimeUnit without amount #247

Merged
merged 2 commits into from Apr 28, 2023

Conversation

ilya-g
Copy link
Member

@ilya-g ilya-g commented Jan 19, 2023

fixes #95, #246

Copy link
Collaborator

@dkhalanskyjb dkhalanskyjb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't find any problems in the proposed replacements, and the general idea is also good.

core/js/src/LocalDate.kt Outdated Show resolved Hide resolved
@@ -381,6 +384,7 @@ public fun Instant.plus(unit: DateTimeUnit.TimeBased): Instant =
*
* The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
*/
@Deprecated("Use the minus overload with explicit amount of units", ReplaceWith("this.minus(1, unit)"))
public fun Instant.minus(unit: DateTimeUnit.TimeBased): Instant =
plus(-1L, unit)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the practice we have in coroutines: when deprecating something, we move it either to the bottom of the file or altogether to a different file designated for deprecated things. This way, the deprecated (and no longer all that relevant) things are out of sight. Maybe we could adopt it here as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll clean up these deprecations near the stabilization, so it's not relevant here. We can consider this practice after stabilization, however I'm not currently fond of it because it makes history digging with git blame harder.

@ilya-g ilya-g merged commit 6b44c6b into master Apr 28, 2023
@ilya-g ilya-g added this to the 0.4.1 milestone Aug 31, 2023
@ilya-g ilya-g deleted the deprecate-plus-datetimeunit branch November 28, 2023 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make DateTimeUnit constructors non public
2 participants