Package Exports
- moment-precise-range-plugin
- moment-precise-range-plugin/moment-precise-range
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (moment-precise-range-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
moment-precise-range
This is a plugin for the moment.js JavaScript library, to display date/time ranges precisely, in a human-readable format.
Moment already contains some support for formatting date/time ranges, however it performs a lot of 'rounding' on the result and yields only an approximate description. In the example below the difference between the 2 dates is 1 month, 2 days, 3 hours, 4 minutes and 5 seconds exactly, however this is simplified to just 'a month' by the library.
var m1 = moment('2014-01-01 12:00:00','YYYY-MM-DD HH:mm:ss'); var m2 = moment('2014-02-03 15:04:05','YYYY-MM-DD HH:mm:ss'); var diff = moment.duration(m1.diff(m2)).humanize(); // 'a month'
Using the plugin, we can display the exact difference using the same 2 dates:
var m1 = moment('2014-01-01 12:00:00','YYYY-MM-DD HH:mm:ss'); var m2 = moment('2014-02-03 15:04:05','YYYY-MM-DD HH:mm:ss'); var diff = moment.preciseDiff(m1, m2); // '1 month 2 days 3 hours 4 minutes 5 seconds'