-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Here is a second unfortunate "feature" of the time extension... The
behavior of time:plus seems to depend on the format used to create the
Logotime variable that is its first argument.
In the attached code, you will see that, in "setup", there are two
alternative statements to initialize the value of sim-start-time. One
initializes this Logotime using text input with millisecond precision
and the second uses input with one hour precision.
The value of sim-start-time is then used to initialize "sim-time", which
is the Logotime variable linked to ticks (in the time:anchor-to-ticks
statement).
To see the problem, do this:
-
Use the first "set sim-start-time" statement, leaving the 2nd one
commented out. -
Click "setup" and then "step", which runs one time step. (I set the
time step to 1.3 hours to make the problem visible.) -
In the Command Center, enter this:
show time:plus sim-time 1.0 "minutes"
You will see that the result is correct: 09:19:00.000
-
Now comment out the first "set sim-start-time" statement and instead
use the second. -
Again use "setup" and "step" and enter the same statement in the
Command Center. Now you will see that the result is wrong: 09:01:00.000
It appears that because sim-time was initialized with another Logotime
that was initialized with hour precision, time:plus truncates its value
to the previous hour before adding to it.
That behavior is certainly not in the documentation and doesn't make
sense to me. I think Logotimes initialized as DateTime values should
always have millisecond precision.
I'm sure this is a mistake from our original version but it raises havoc
with discrete event simulation and was not easy to find!