timespan comparison
desaxxx opened this issue ยท 6 comments
Skript/Server Version
Skript version 2.8.7
Customize Minecraft's mechanics with simple scripts written in plain English sentences.
Website: https://skriptlang.org
Authors: Njol, Mirreski, SkriptLang Team and Contributors
Server version 1.19.4
Bug Description
So there was a timespan comparison in my script but it doesn't work as expected. I have a variable that stores dates, and i check it with 'time since' effect and compare it with a timespan as i will upload a screenshot. Event though the time exceed given timespan, it goes for other way.
Expected Behavior
It should be able to compare it correctly.
Steps to Reproduce
This is the code:
/command /time:
trigger:
if time since ({restourant hirechef date::%player%} ? 6 hours ago) >= 6 hours:
send "its exceed 6 hours, %time since {restourant hirechef date::%player%}%"
else:
send "its not exceed 6 hours. %time since {restourant hirechef _date::%player%}%"
Also tried 'is greater than or equal to' effect and tried without the '? 6 hours ago' part. No change.
Errors or Screenshots
This is what is says after using the command i stated above.
Other
No response
Agreement
- I have read the guidelines above and affirm I am following them with this report.
The variable is set to a timespan, not a date. The time since
expression works on dates, not timespans.
Nevermind i really need to get my eyes checked, I didn't see the time since
in the message effect. My apologies.
dev/patch is not updated. dev/feature is
they are both updated, one has the latest patches and one has the latest features
Can confirm this happens on latest dev/patch, although for me the cause is the
otherwise
.command /test: trigger: set {_x} to 2 hours ago if time since {_x} >= 1 hour: send ">= 1 hour ago" else: send "< 1 hour ago"
returns
>= 1 hour ago
as it should, butcommand /test: trigger: set {_x} to 2 hours ago if time since ({_x} ? 2 hours ago) >= 1 hour: send ">= 1 hour ago" else: send "< 1 hour ago"
returns
<1 hour ago
.EDIT: seems to be fixed by adding parenthesis around the expression after the ?, so
command /test: trigger: set {_x} to 2 hours ago if time since ({_x} ? (2 hours ago)) >= 1 hour: send ">= 1 hour ago" else: send "< 1 hour ago"
works.
ahhh it's parsing ({_x} ? 2 hours) ago
and getting none because wrong type
Can confirm this happens on latest dev/patch, although for me the cause is the otherwise
.
command /test:
trigger:
set {_x} to 2 hours ago
if time since {_x} >= 1 hour:
send ">= 1 hour ago"
else:
send "< 1 hour ago"
returns >= 1 hour ago
as it should, but
command /test:
trigger:
set {_x} to 2 hours ago
if time since ({_x} ? 2 hours ago) >= 1 hour:
send ">= 1 hour ago"
else:
send "< 1 hour ago"
returns <1 hour ago
.
EDIT: seems to be fixed by adding parenthesis around the expression after the ?, so
command /test:
trigger:
set {_x} to 2 hours ago
if time since ({_x} ? (2 hours ago)) >= 1 hour:
send ">= 1 hour ago"
else:
send "< 1 hour ago"
works.