Skip to content
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

Update is-between API description #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions docs/plugin/is-between.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ title: IsBetween
---
IsBetween adds `.isBetween()` API to returns a `boolean` indicating if a date is between two other dates.


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about move this part to the end of the file?

```typescript
.isBetween(startDate: String, endDate: String, precision?: String, inclusion?: String): Boolean
```
Parameter |Type| Description
---|---|---
startDate |String| Representing a valid date will be automatically parsed as dayjs date
endDate |String| Representing a valid date will be automatically parsed as dayjs date
precision |String| Granuality offers the precision on start and end inclusive checks. `years`, `month`, `day`...
inclusion |String| String with two characters, offers the precision on start and end inclusive checks '[' means inclusive, '(' mean exclusive... eg: '()' excludes start and end date (default); '[]' includes start and end date; '[)' includes the start date but excludes the stop

```javascript
var isBetween = require('dayjs/plugin/isBetween')
dayjs.extend(isBetween)

// To use `year` granularity pass the third parameter
dayjs('2010-10-20').isBetween('2010-10-19', dayjs('2010-10-25'), 'year')

// Parameter 4 is a string with two characters; '[' means inclusive, '(' exclusive
// '()' excludes start and end date (default)
// '[]' includes start and end date
// '[)' includes the start date but excludes the stop
// Granuality offers the precision on start and end inclusive checks.
// For example including the start date on day precision you should use 'day' as 3rd parameter.
dayjs('2016-10-30').isBetween('2016-01-01', '2016-10-30', 'day', '[)')

Expand Down