-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isBetween inclusivity solved #429
Comments
Maybe you could create a PR with the changes? |
Can I submit a pull request for this? |
@waseemahmad31 sure 😀 |
added in #464 |
Update: Support isBetween() API https://day.js.org/docs/en/query/is-between |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I leave my two cents for isBetween functionality.
That's an approach of moment.js way to treat inclusivity, it can be added to isBetween plugin:
code:
export type DayjsInclusivity = '()' | '[)' | '(]' | '[]';
isBetween(date: Dayjs, dateStart: Dayjs, dateEnd: Dayjs, precision?: UnitType, inclusivity?: DayjsInclusivity ) {
let result = dayjs(date).isAfter(dateStart, precision) && dayjs(date).isBefore(dateEnd, precision);
if (!result && (inclusivity || inclusivity !== '()')) {
if (inclusivity === '[)') {
result = dayjs(date).isSame(dateStart, precision);
} else if (inclusivity === '(]') {
result = dayjs(date).isSame(dateEnd, precision);
} else {
result = dayjs(date).isSame(dateStart, precision) && dayjs(date).isSame(dateEnd, precision);
}
}
return result;
}
The text was updated successfully, but these errors were encountered: