Skript

Skript

743k Downloads

Timespan#getAs(TimePeriod) truncates to Integer, breaking larger timespans.

Diclo opened this issue ยท 8 comments

commented

Skript/Server Version

Server: 1.21-75
Skript: Skript-2.9.0

Bug Description

The time subtraction function isn't working.

script:
set {_pcd} to skutil yaml value "cd.%{_tipo}%" of file "{@file}"
send "%nl% Tiempo guardado: %{_pcd}% %nl%" to console
set {_pcd} to "%{_pcd}% seconds" parsed as timespan
send "%nl% Tiempo convertido: %{_pcd}% %nl%" to console
set {_pcd-hoy} to convert date now to unix date
set {_pcd-hoy} to "%{_pcd-hoy}% seconds" parsed as timespan
send "%nl% Tiempo hoy: %{_pcd-hoy}% %nl%" to console
subtract {_pcd} from {_pcd-hoy}
send "%nl% tiempo restado: %{_pcd-hoy}% %nl%" to console

When performing the subtraction of {_pcd} and {_pcd-hoy}, it always results in 0.

imagen

Expected Behavior

The result should be the remaining time.

imagen

Steps to Reproduce

command /redem:
trigger:
set {_pcd} to skutil yaml value "cd.%{_tipo}%" of file "{@file}"
send "%nl% Tiempo guardado: %{_pcd}% %nl%" to console
set {_pcd} to "%{_pcd}% seconds" parsed as timespan
send "%nl% Tiempo convertido: %{_pcd}% %nl%" to console
set {_pcd-hoy} to convert date now to unix date
set {_pcd-hoy} to "%{_pcd-hoy}% seconds" parsed as timespan
send "%nl% Tiempo hoy: %{_pcd-hoy}% %nl%" to console
subtract {_pcd} from {_pcd-hoy}
send "%nl% tiempo restado: %{_pcd-hoy}% %nl%" to console

Errors or Screenshots

No response

Other

No response

Agreement

  • I have read the guidelines above and affirm I am following them with this report.
commented

can you send your /sk info?

commented

imagen

commented

Was this working prior to 2.9.0?

commented

Was this working prior to 2.9.0?

Yes, for example, this is the productivity server:
imagen
imagen

commented

I wonder if we're running into integer overflow. I'll investigate further.

commented

Yes, Math.round() is truncating the value to an integer.
image

commented

Workaround for now is just to do the math before parsing as timespan.

commented

Workaround for now is just to do the math before parsing as timespan.

Subtract while both are in Unix date format
oka thanks c: