I want to reliably find the days between two dates in a Lightning Component and https://momentjs.com/ has this capability. But does it work with the July 2017 Locker Service?
This Moment JS format returns function string in Lightning Spring 17 could be interpreted as saying that it should.
But it is not listed in this February 2017 LockerService and Lightning Container Component: Securely Using Third-Party Libraries in Lightning Components and is mentioned in the comments as being a source of some difficulty.
Best Answer
Just played around with the latest version of Moment.js , 2.18.1 and seems to play nicely with locker .
Summer 17 whitelisted InstanceOf operator in locker API and that seems to have made Moment.js compatible with locker .
Here are the functions and components that i just tested and seemed to work fine
The Controller class
The console seems to print all the results as expected
Here is a sample MomentJs code that works under locker to find difference between dates