Support js date objects as first and last date

My project that uses javascript dates was working with version 4.2.0 and broke with the newest version. This fix brings back the compatibility that was there previously.