2016-01-20 02:11:20 +00:00
|
|
|
import moment from 'moment-timezone';
|
2015-12-10 22:52:09 +00:00
|
|
|
|
|
|
|
// day count between two epochs (inclusive)
|
2016-01-20 02:11:20 +00:00
|
|
|
export function dayCount([head, tail], timezone = 'UTC') {
|
2015-12-10 22:52:09 +00:00
|
|
|
return Math.ceil(
|
2016-02-09 17:10:18 +00:00
|
|
|
moment(moment(head).tz(timezone).endOf('day')).diff(
|
2016-01-20 02:11:20 +00:00
|
|
|
moment(tail).tz(timezone).startOf('day'),
|
2016-01-03 04:39:47 +00:00
|
|
|
'days',
|
2015-12-10 22:52:09 +00:00
|
|
|
true)
|
|
|
|
);
|
|
|
|
}
|