QbaF
7 March 2020 16:38
22
No, TotallyInformation says:
You would need to look up the issue I raised
But thank you. Especially for that link you gave (also because in that link is now the link I was asking for). Rest about this work around was completely clear and I appreciate it.
QbaF
7 March 2020 16:50
23
I saw it. My question is why 3+ digital point is issue only in same (minor) cases?
Yes, sorry, I had a memory failure. It is actually the parser that is wrong not MomentJS. The last time I tested Moment, it could handle up to 9dp's I think.
opened 09:57PM - 25 May 19 UTC
The following code:
```javascript
var moment = require('moment')
var parseFā¦ ormat = require('moment-parseformat')
var dp6 = "2019-05-25T15:30:42.526058+00:00"
var dp5 = "2019-05-25T15:30:42.52605+00:00"
var long6dp = moment(dp6)
var long5dp = moment(dp5)
var fmt6dp = parseFormat(dp6,{preferredOrder: {'/': 'DMY', '.': 'DMY', '-': 'YMD'}})
var fmt5dp = parseFormat(dp5,{preferredOrder: {'/': 'DMY', '.': 'DMY', '-': 'YMD'}})
var fmt6dpMoment = moment(dp6, fmt6dp)
var fmt5dpMoment = moment(dp5, fmt5dp)
console.log( 'long6dp', long6dp.format() )
console.log( 'long5dp', long5dp.format() )
console.log( 'fmt6dp parseFormat', fmt6dp )
console.log( 'fmt5dp parseFormat', fmt5dp )
console.log( 'fmt6dpMoment', fmt6dpMoment.format() )
console.log( 'fmt5dpMoment', fmt5dpMoment.format() )
```
Produces the following output:
```
long6dp 2019-05-25T16:30:42+01:00
long5dp 2019-05-25T16:30:42+01:00
fmt6dp parseFormat YYYY-MM-DDTHH:mm:ss.SSSDDDZ
fmt5dp parseFormat YYYY-MM-DDTHH:mm:ss.SSSDDZ
fmt6dpMoment 2019-02-27T15:30:42+00:00
fmt5dpMoment 2019-05-05T16:30:42+01:00
```
As you can see, anything beyond 3DP on the seconds value results in "D" specifications on the end of the fractional seconds which is clearly incorrect and produces uncertain output from moment.
Reported to me in the following issue:
https://github.com/TotallyInformation/node-red-contrib-moment/issues/24
It is the way that the parser uses a regular expression. It ends up with an incorrect date being used.
system
Closed
6 May 2020 16:53
26
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.