Open adroste opened 2 years ago
format seems to be broken entirely for me as well, only weird results coming out of it so far...
I'm going to add another failure case:
SSS
is supposed to give milliseconds to 3 digits according to the documentation but if a fractional value is given to duration()
then SSS also gives fractions in the output.
daysjs.duration(16030.000000000002).format('HH:mm:ss.SSS');
// outputs 00:00:16.30.00000000000182
Just to add a note, dayjsLib.duration({ seconds }).format(format)
does not work, but dayjsLib.duration(seconds * 1000).format(format)
does.
Describe the bug Every duration instance I create whether from ISO-string or from object appears to be broken. The behaviour is also inconsistent between construction from ISO-string or object.
Case 1 (init leaves undefined values, inconsistent):
and weirdly:
Case 2 (milliseconds parsing from ISO string):
but from ISO string, parsing is completely broken:
Case 3 (overflows not calculated on creation):
Case 4 (overflow calculation ignores format options)
Workaround
Cases 1,2,3 can be worked around by adding nothing (
.add(0,'s')
), like:@iamkun Feels like you forgot to call an init function inside the constructor.
Information