spencermountain / spacetime

A lightweight javascript timezone library
http://spacetime.how/
Other
3.99k stars 183 forks source link

An inclusive version of isBetween #195

Closed coatesap closed 4 years ago

coatesap commented 4 years ago

Wanting to check whether a date falls inside an "inclusive" date range is quite common. At the moment, isBetween() doesn't match against the start and end dates. Having an isBetweenInclusive() method would be very handy.

Presumably the implementation would be:

isBetweenInclusive: function(start, end) {
    return this.isBetween(start, end) || this.isEqual(start) || this.isEqual(end);
}

If that sounds sensible, I'm happy to open a PR for it.

ElRaymond0 commented 4 years ago

I concur

spencermountain commented 4 years ago

hey Andy - maybe isBetween should just be inclusive? i don't have strong thoughts about that either way.

jecraig commented 4 years ago

@spencermountain What if we just pass in an optional boolean to be inclusive. Default to false/null that way we don't break any existing code relying on it not being inclusive.

spencermountain commented 4 years ago

Yep I like that too. Good idea, pr welcome.

On Fri, Mar 6, 2020 at 4:11 PM Jacob Craig notifications@github.com wrote:

@spencermountain https://github.com/spencermountain What if we just pass in an optional boolean to be inclusive. Default to false/null that way we don't break any existing code relying on it not being inclusive.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/spencermountain/spacetime/issues/195?email_source=notifications&email_token=AADBSKJBZM2BZ6XNVLGJBOTRGFRHBA5CNFSM4LDDDYSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOC3X6Y#issuecomment-595966971, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADBSKNJFX5H7V2HHFK2UFLRGFRHBANCNFSM4LDDDYSA .

spencermountain commented 4 years ago

will release this as 6.5.0 over the next few days. cheers