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

Timespan <-> Duration Conversion methods. #6993

Merged
merged 2 commits into from
Aug 30, 2024

Conversation

Moderocky
Copy link
Member

Description

Adds two simple converter methods for Skript Timespan <-> Java Duration.

Duration is the common Java timespan class, which is probably more useful to addon developers.

Since the direct milliseconds method in Timespan was deprecated and the replacement requires a few more steps to use, I thought it would be nice to have a converter for anybody wanting durations for external API.

Copy link
Contributor

@Fusezion Fusezion left a comment

Choose a reason for hiding this comment

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

Big fan of this addition

@Moderocky
Copy link
Member Author

But wait! It gets better!!

A lot of the Java 8 time stuff is an interface (designed for overrides from the SQL library) so I implemented them (based on built-in Duration and ChronoUnit) and so Skript's Timespan class should now be usable in a lot of Java & API time-related methods as-is.

Of course there is the caveat that Skript months are all 30 days but I don't think that's a major drawback.

@APickledWalrus APickledWalrus added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Aug 22, 2024
@Moderocky Moderocky added the feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. label Aug 30, 2024
@Moderocky Moderocky merged commit 4e584b2 into SkriptLang:dev/feature Aug 30, 2024
3 checks passed
@Moderocky Moderocky deleted the timespan-to-duration branch August 30, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants