[错误] moment.duration 可以接受浮点小数毫秒
作者: martin770创建于 2018年6月1日更新于 2026年9月2日
标签floating-point
文档中指出: 要获取持续时间中的毫秒数,请使用 moment.duration().milliseconds()。它将返回一个介于 0 和 999 之间的数值。 然而, `moment.duration(1.23).milliseconds()` 返回 `1.23` `moment.duration(1.23).asMilliseconds()` 返回 `1.23` (这似乎是正确的) 为了与其他持续时间函数(例如 seconds(), asSeconds(), minutes(), asMinutes())保持一致, `moment.duration(1.23).milliseconds()` 应返回 `1` (一个介于 0 和 999 之间的整数),但 `moment.duration(1.23).asMilliseconds()` 应返回 `1.23`。
内容来源: moment/moment