19 lines
353 B
JavaScript
Raw Normal View History

import moment from 'moment-timezone';
// day count between two epochs (inclusive)
export function dayCount([head, tail], timezone = 'UTC') {
return Math.ceil(
moment(
moment(head)
.tz(timezone)
.endOf('day')
).diff(
moment(tail)
.tz(timezone)
.startOf('day'),
2016-01-03 05:39:47 +01:00
'days',
true
)
2019-02-06 14:19:58 +00:00
);
}