You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use the Duration object to create a countdown clock by using the minus function to subtract a second. But it seems that the minus function operates on the units (e.g. seconds) independently.
Steps to reproduce
var duration = Duration.fromObject({minutes: 1, seconds: 0})
var time = `${duration.minutes} : ${duration.seconds.toString().padStart(2, '0')}`
var newDuration = duration.minus({seconds: 1});
var newTime = `${duration.minutes} : ${duration.seconds.toString().padStart(2, '0')}`
Expected:
time: 1:00
newTime: 0:59
Actual:
time: 1:00
newTime: 1:-1
The text was updated successfully, but these errors were encountered:
@icambron
It seems the behavior is inconsistent. If I had to guess I would say that if the upper unit is present, then it's automatically subtracting from it, if not, then it goes into negative.
Please, check this codesandbox.
I'm trying to use the Duration object to create a countdown clock by using the minus function to subtract a second. But it seems that the minus function operates on the units (e.g. seconds) independently.
Steps to reproduce
Expected:
time: 1:00
newTime: 0:59
Actual:
time: 1:00
newTime: 1:-1
The text was updated successfully, but these errors were encountered: