icambron / twix.js

:hourglass::left_right_arrow: A date range plugin for moment.js
https://isaaccambron.com/twix.js/
MIT License
379 stars 54 forks source link

Interoperability with moment-range #114

Closed strarsis closed 5 years ago

strarsis commented 5 years ago

Can a twix range converted to a moment-range and back? The all-day range option of twix is very useful for me, but most of the code already uses moment-range.

icambron commented 5 years ago

Sure. To go from Twix to moment-range, just do

var range = moment.range(twix.start(), twix.end());

To go the other way:

var twix = range.start.twix(range.end);

(I haven't tested either of those, but I'm pretty sure they work)