Add "Time Until" to ExprTimeSince and Add CondPastFuture#6203
Merged
Conversation
Adds condition for checking whether dates are in the past or the future
Closed
APickledWalrus
requested changes
Dec 18, 2023
Moderocky
approved these changes
Apr 13, 2024
Member
Moderocky
left a comment
There was a problem hiding this comment.
Good, maybe should have been 2 separate PRs though
Efnilite
requested changes
Sep 10, 2024
Efnilite
approved these changes
Sep 11, 2024
cheeezburga
approved these changes
Sep 11, 2024
APickledWalrus
approved these changes
Oct 13, 2024
| } | ||
|
|
||
| // using the same 'now' date for all checks is flawed, because the input dates are evaluated during the | ||
| // check, so it could cause 'now is in the future' to be true, when it should be false. |
Member
There was a problem hiding this comment.
Isn't the now case already checked above though?
Member
Author
There was a problem hiding this comment.
Yes this was written prior to the ExprNow checks, but technically still applicable with other scenarios
erenkarakal
pushed a commit
to erenkarakal/Skript
that referenced
this pull request
Nov 26, 2025
…6203) * Time Until * ghost of christmas past Adds condition for checking whether dates are in the past or the future * Update CondPastFuture.java * Update CondPastFuture.java * Make tests more reliable * Requested changes * requested changes, fix merge issue --------- Co-authored-by: Moderocky <admin@moderocky.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Continuation of #5767 as previous author did not want to continue working on it.
Also adds CondPastFuture for testing whether a date is in the past or the future. This is simply a more intuitive syntax for
if {_x} < nowthat also supports multiple dates:This has the issue of being unreliable when using ExprNow (who would do that) so there's an explicit check for ExprNow instead of relying on chance for the two created dates to be the same. I added a check for ExpressionLists with ExprNow in them, but I'm not sure that's worth checking.
breaking change of returning 0 seconds for out-of-range dates instead of null:
Previously I disagreed with this change, as seen here:
However, I've thought more about it and I think it has benefits outside of intuition. Returning 0 seconds instead of null allows comparisons to be more reliable, since the returned value is still a timespan and will evaluate accordingly instead of being null and being related to negation.
However, it does cause some significant change. Users may rely on the future date to be null, for example using
if time since xto test if a date is in the past instead of usingif x is less than now.More opinions are welcome!
Target Minecraft Versions: any
Requirements: none
Related Issues: #5766