I created a timer application to be run in a terminal window.
I'm witnessing some strange behavior in time.Time.Sub()
when I start a terminal timer and put my macOS laptop running it to sleep by closing it.
When I reopen the laptop, suddenly the function appears to not work properly, as tracked by this block of code, which can be seen in this copied output to miscalculate unless I am misunderstanding the time.Time
values:
== 615a Timer ==
20m59s
now: 2018-04-27 05:58:20.440440541 -0700 PDT m=+310.234277006
exactLeft: 20m59.142673336s
t.end: 2018-04-27 06:15:00.000129434 -0700 PDT m=+1569.376950342
t.end.Sub(now): 20m59.142673336s
Explicitly, now
is set to 5:58
and t.end
is set to 6:15
, which has a duration of 17m
. Yet, t.end.Sub(now)
evaluates to 21m
, which is a difference of about the time that my laptop was asleep. What is happening here?