#4127·moment

from()/to() 计算月份周围的日期错误

作者: pretender创建于 2017年8月17日更新于 2026年9月2日
标签Bugrelative time threshold issues

** 说明问题和重述步骤:**

到()/从( 从) 得到的非常不同日期的结果相同 : {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你来干什么? 第一刻 = 需要('moment') var 已过期At = moment ('2017-07-16T21:01:54.249Z'). var now=moment ('2017-08-16T00:02:01.249Z') (中文(简体) ). ("2017-08-17T00:02:01.249Z') (中文(简体) ).

现在. to(已过期) // “ 一个月前” (预期) 明天. to(已过期)//'一个月前'(预期)

瞬间。相对时间危险('d', 180) 现在. to(已过期)//'30天'(预计) 明天. to(已过期)//'30天'(意外)

请不要。 也许数学里有3000000001和3099999999的值,让我们看看:
{\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你来干什么?
moment. relativeTimeRounding(v {{ return v;}) 时间轴 :
现在.to(已过期) / '30.125081018518518天' (好, 好)
明天(已过期) / '30.125081018518518天前'

上帝,请,没有。 他们是一样的! {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你来干什么? 已过期 。 现在.format ("x") //'1502841721249' Controber.log ((1502841721249 - 1500238914249)/1000/60/60/24)/ 30.125081018518518 (英语).

明天.format ('x') //'1502928121249' (中文(简体) ). consember.log ((1502928121249 - 1500238914249)/1000/60/60/24)/31125081018518518 (英语).


** 环境:**

Debian 8.7, Node.js v 4.4.7, moment.JS v2.15.2, TZ='America/New York' (英语).
Debian 8.8, Node.js v 6.9.2, Moment.JS v2.18.1, TZ='欧洲/柏林'