Skip to content

Commit

Permalink
fix(): update isSame isBefore isAfter
Browse files Browse the repository at this point in the history
fix(): update api && add plugin
  • Loading branch information
iamkun authored Dec 13, 2018
2 parents 3b47264 + 8390e64 commit fd65464
Show file tree
Hide file tree
Showing 14 changed files with 294 additions and 69 deletions.
29 changes: 23 additions & 6 deletions docs/en/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ The `Dayjs` object is immutable, that is, all API operations that change the `Da
- [As Object `.toObject()`](#as-object-toobject)
- [As String `.toString()`](#as-string-tostring)
- [Query](#query)
- [Is Before `.isBefore(compared: Dayjs)`](#is-before-isbeforecompared-dayjs)
- [Is Same `.isSame(compared: Dayjs)`](#is-same-issamecompared-dayjs)
- [Is After `.isAfter(compared: Dayjs)`](#is-after-isaftercompared-dayjs)
- [Is Before `.isBefore(compared: Dayjs, unit?: string)`](#is-before-isbeforecompared-dayjs-unit-string)
- [Is Same `.isSame(compared: Dayjs, unit?: string)`](#is-same-issamecompared-dayjs-unit-string)
- [Is After `.isAfter(compared: Dayjs, unit?: string)`](#is-after-isaftercompared-dayjs-unit-string)
- [Is a Dayjs `.isDayjs()`](#is-a-dayjs-isdayjscompared-any)
- [Plugin APIs](#plugin-apis)
- [RelativeTime](#relativetime)
- [IsLeapYear](#isleapyear)
- [WeekOfYear](#weekofyear)
- [IsSameOrAfter](#issameorafter)
- [IsSameOrBefore](#issameorbefore)
- [IsBetween](#isbetween)

## Parsing
Expand Down Expand Up @@ -383,28 +385,31 @@ dayjs('2019-01-25').toString(); // 'Fri, 25 Jan 2019 02:00:00 GMT'

## Query

### Is Before `.isBefore(compared: Dayjs)`
### Is Before `.isBefore(compared: Dayjs, unit?: string)`

Returns a `boolean` indicating whether the `Dayjs`'s date is before the other supplied `Dayjs`'s.

```js
dayjs().isBefore(dayjs()); // false
dayjs().isBefore(dayjs(), 'year'); // false
```

### Is Same `.isSame(compared: Dayjs)`
### Is Same `.isSame(compared: Dayjs, unit?: string)`

Returns a `boolean` indicating whether the `Dayjs`'s date is the same as the other supplied `Dayjs`'s.

```js
dayjs().isSame(dayjs()); // true
dayjs().isSame(dayjs(), 'year'); // true
```

### Is After `.isAfter(compared: Dayjs)`
### Is After `.isAfter(compared: Dayjs, unit?: string)`

Returns a `boolean` indicating whether the `Dayjs`'s date is after the other supplied `Dayjs`'s.

```js
dayjs().isAfter(dayjs()); // false
dayjs().isAfter(dayjs(), 'year'); // false
```

### Is a Dayjs `.isDayjs(compared: any)`
Expand Down Expand Up @@ -436,6 +441,18 @@ plugin [`IsLeapYear`](./Plugin.md#isleapyear)

plugin [`WeekOfYear`](./Plugin.md#weekofyear)

### IsSameOrAfter

`.isSameOrAfter` to check if a date is same of after another date

plugin [`IsSameOrAfter`](./Plugin.md#issameorafter)

### IsSameOrBefore

`.isSameOrBefore` to check if a date is same of before another date.

plugin [`IsSameOrBefore`](./Plugin.md#issameorbefore)

### IsBetween

`.isBetween` to check if a date is between two other dates
Expand Down
24 changes: 23 additions & 1 deletion docs/en/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,28 @@ dayjs.extend(weekOfYear)
dayjs('06/27/2018').week() // 26
```

### IsSameOrAfter
- IsSameOrAfter adds `.isSameOrAfter()` API to returns a `boolean` indicating if a date is same of after another date.

```javascript
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'

dayjs.extend(isSameOrAfter)

dayjs('2010-10-20').isSameOrAfter('2010-10-19', 'year');
```

### IsSameOrBefore
- IsSameOrBefore adds `.isSameOrBefore()` API to returns a `boolean` indicating if a date is same of before another date.

```javascript
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'

dayjs.extend(isSameOrBefore)

dayjs('2010-10-20').isSameOrBefore('2010-10-19', 'year');
```

### IsBetween
- IsBetween adds `.isBetween()` API to returns a `boolean` indicating if a date is between two other dates.

Expand All @@ -163,7 +185,7 @@ import isBetween from 'dayjs/plugin/isBetween'

dayjs.extend(isBetween)

dayjs('2010-10-20').isBetween('2010-10-19', dayjs('2010-10-25')); // true
dayjs('2010-10-20').isBetween('2010-10-19', dayjs('2010-10-25'), 'year');
```

## Customize
Expand Down
29 changes: 23 additions & 6 deletions docs/es-es/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ El objeto `Dayjs` es inmutable, por lo que toda operación de la API que altere
- [Como objeto `.toObject()`](#como-objecto-toobject)
- [Como cadena `.toString()`](#como-cadena-tostring)
- [Consulta](#consulta)
- [Anterior a `.isBefore(compared: Dayjs)`](#anterior-a-isbeforecompared-dayjs)
- [Igual que `.isSame(compared: Dayjs)`](#igual-que-issamecompared-dayjs)
- [Posterior a `.isAfter(compared: Dayjs)`](#posterior-a-isaftercompared-dayjs)
- [Anterior a `.isBefore(compared: Dayjs, unit?: string)`](#anterior-a-isbeforecompared-dayjs-unit-string)
- [Igual que `.isSame(compared: Dayjs, unit?: string)`](#igual-que-issamecompared-dayjs-unit-string)
- [Posterior a `.isAfter(compared: Dayjs, unit?: string)`](#posterior-a-isaftercompared-dayjs-unit-string)
- [Es Dayjs `.isDayjs()`](#es-dayjs-isdayjscompared-any)
- [API de complementos](#api-de-complementos)
- [RelativeTime](#relativetime)
- [IsLeapYear](#isleapyear)
- [WeekOfYear](#weekofyear)
- [IsSameOrAfter](#issameorafter)
- [IsSameOrBefore](#issameorbefore)
- [IsBetween](#isbetween)

## Análisis
Expand Down Expand Up @@ -383,28 +385,31 @@ dayjs('2019-01-25').toString(); // 'Fri, 25 Jan 2019 02:00:00 GMT'

## Consulta

### Anterior a `.isBefore(compared: Dayjs)`
### Anterior a `.isBefore(compared: Dayjs, unit?: string)`

Devuelve un dato de tipo `boolean`, que indica si la fecha del objeto `Dayjs` inicial es anterior o no a la fecha del objeto `Dayjs` a comparar.

```js
dayjs().isBefore(dayjs()); // false
dayjs().isBefore(dayjs(), 'year'); // false
```

### Igual que `.isSame(compared: Dayjs)`
### Igual que `.isSame(compared: Dayjs, unit?: string)`

Devuelve un dato de tipo `boolean`, que indica si la fecha del objeto `Dayjs` inicial es igual o no que la fecha del objeto `Dayjs` a comparar.

```js
dayjs().isSame(dayjs()); // true
dayjs().isSame(dayjs(), 'year'); // true
```

### Posterior a `.isAfter(compared: Dayjs)`
### Posterior a `.isAfter(compared: Dayjs, unit?: string)`

Devuelve un dato de tipo `boolean`, que indica si la fecha del objeto `Dayjs` inicial es posterior o no a la fecha del objeto `Dayjs` a comparar.

```js
dayjs().isAfter(dayjs()); // false
dayjs().isAfter(dayjs(), 'year'); // false
```

### Es Dayjs `.isDayjs(compared: any)`
Expand Down Expand Up @@ -436,6 +441,18 @@ complemento [`IsLeapYear`](./Plugin.md#isleapyear)

complemento [`WeekOfYear`](./Plugin.md#weekofyear)

### IsSameOrAfter

`.isSameOrAfter` to check if a date is same of after another date

plugin [`IsSameOrAfter`](./Plugin.md#issameorafter)

### IsSameOrBefore

`.isSameOrBefore` to check if a date is same of before another date.

plugin [`IsSameOrBefore`](./Plugin.md#issameorbefore)

### IsBetween

`.isBetween` para comprobar si una fecha se encuentra entre otras dos fechas dadas
Expand Down
24 changes: 23 additions & 1 deletion docs/es-es/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,28 @@ dayjs.extend(weekOfYear)
dayjs('06/27/2018').week() // 26
```

### IsSameOrAfter
- IsSameOrAfter adds `.isSameOrAfter()` API to returns a `boolean` indicating if a date is same of after another date.

```javascript
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'

dayjs.extend(isSameOrAfter)

dayjs('2010-10-20').isSameOrAfter('2010-10-19', 'year');
```

### IsSameOrBefore
- IsSameOrBefore adds `.isSameOrBefore()` API to returns a `boolean` indicating if a date is same of before another date.

```javascript
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'

dayjs.extend(isSameOrBefore)

dayjs('2010-10-20').isSameOrBefore('2010-10-19', 'year');
```

### IsBetween

* IsBetween añade la API `.isBetween()`, que devuelve un dato de tipo `boolean` indicando si una fecha se encuentra o no entre otras dos dadas.
Expand All @@ -170,7 +192,7 @@ import isBetween from 'dayjs/plugin/isBetween'

dayjs.extend(isBetween)

dayjs('2010-10-20').isBetween('2010-10-19', dayjs('2010-10-25')); // true
dayjs('2010-10-20').isBetween('2010-10-19', dayjs('2010-10-25'), 'year');
```

## Personalización
Expand Down
23 changes: 20 additions & 3 deletions docs/ja/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Day.js は組み込みの `Date.prototype` を変更する代わりに `Dayjs`
* [RelativeTime](#relativetime)
* [IsLeapYear](#isleapyear)
* [WeekOfYear](#weekofyear)
* [IsSameOrAfter](#issameorafter)
* [IsSameOrBefore](#issameorbefore)
* [IsBetween](#isbetween)

---
Expand Down Expand Up @@ -451,8 +453,9 @@ dayjs().toString();
`Dayjs` オブジェクトが別の `Dayjs` オブジェクト以前の値かどうかを判定します。

```js
dayjs().isBefore(Dayjs);
dayjs().isBefore(Dayjs, unit? : String);
dayjs().isBefore(dayjs()); // false
dayjs().isBefore(dayjs(), 'year'); // false
```

#### Is Same
Expand All @@ -462,8 +465,9 @@ dayjs().isBefore(dayjs()); // false
`Dayjs` オブジェクトが別の `Dayjs` オブジェクトの値と等しいかどうかを判定します。

```js
dayjs().isSame(Dayjs);
dayjs().isSame(Dayjs, unit? : String);
dayjs().isSame(dayjs()); // true
dayjs().isSame(dayjs(), 'year'); // true
```

#### Is After
Expand All @@ -473,8 +477,9 @@ dayjs().isSame(dayjs()); // true
`Dayjs` オブジェクトが別の `Dayjs` オブジェクト以降の値かどうかを判定します。

```js
dayjs().isAfter(Dayjs);
dayjs().isAfter(Dayjs, unit? : String);
dayjs().isAfter(dayjs()); // false
dayjs().isAfter(dayjs(), 'year'); // false
```

### Is a Dayjs `.isDayjs(compared: any)`
Expand Down Expand Up @@ -506,6 +511,18 @@ plugin [`IsLeapYear`](./Plugin.md#isleapyear)

plugin [`WeekOfYear`](./Plugin.md#weekofyear)

### IsSameOrAfter

`.isSameOrAfter` to check if a date is same of after another date

plugin [`IsSameOrAfter`](./Plugin.md#issameorafter)

### IsSameOrBefore

`.isSameOrBefore` to check if a date is same of before another date.

plugin [`IsSameOrBefore`](./Plugin.md#issameorbefore)

### IsBetween

`.isBetween` to check if a date is between two other dates
Expand Down
23 changes: 22 additions & 1 deletion docs/ja/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,27 @@ dayjs.extend(weekOfYear)

dayjs('06/27/2018').week() // 26
```
### IsSameOrAfter
- IsSameOrAfter adds `.isSameOrAfter()` API to returns a `boolean` indicating if a date is same of after another date.

```javascript
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'

dayjs.extend(isSameOrAfter)

dayjs('2010-10-20').isSameOrAfter('2010-10-19', 'year');
```

### IsSameOrBefore
- IsSameOrBefore adds `.isSameOrBefore()` API to returns a `boolean` indicating if a date is same of before another date.

```javascript
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'

dayjs.extend(isSameOrBefore)

dayjs('2010-10-20').isSameOrBefore('2010-10-19', 'year');
```

### IsBetween
- IsBetween adds `.isBetween()` API to returns a `boolean` indicating if a date is between two other dates.
Expand All @@ -164,7 +185,7 @@ import isBetween from 'dayjs/plugin/isBetween'

dayjs.extend(isBetween)

dayjs('2010-10-20').isBetween('2010-10-19', dayjs('2010-10-25')); // true
dayjs('2010-10-20').isBetween('2010-10-19', dayjs('2010-10-25'), 'year');
```

## カスタマイズ
Expand Down
29 changes: 23 additions & 6 deletions docs/ko/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ Day.js는 네이티브 `Date.prototype`을 수정하는 대신 `Dayjs` 오브젝
- [As Object `.toObject()`](#as-object-toobject)
- [As String `.toString()`](#as-string-tostring)
- [Query](#query)
- [Is Before `.isBefore(compared: Dayjs)`](#is-before-isbeforecompared--dayjs)
- [Is Same `.isSame(compared: Dayjs)`](#is-same-issamecompared--dayjs)
- [Is After `.isAfter(compared: Dayjs)`](#is-after-isaftercompared--dayjs)
- [Is Before `.isBefore(compared: Dayjs, unit?: string)`](#is-before-isbeforecompared--dayjs-unit-string)
- [Is Same `.isSame(compared: Dayjs, unit?: string)`](#is-same-issamecompared--dayjs-unit-string)
- [Is After `.isAfter(compared: Dayjs, unit?: string)`](#is-after-isaftercompared--dayjs-unit-string)
- [Is a Dayjs `.isDayjs()`](#is-a-dayjs-isdayjscompared-any)
- [Plugin APIs](#plugin-apis)
- [RelativeTime](#relativetime)
- [IsLeapYear](#isleapyear)
- [WeekOfYear](#weekofyear)
- [IsSameOrAfter](#issameorafter)
- [IsSameOrBefore](#issameorbefore)
- [IsBetween](#isbetween)

## Parsing
Expand Down Expand Up @@ -382,28 +384,31 @@ dayjs('2019-01-25').toString(); // 'Fri, 25 Jan 2019 02:00:00 GMT'

## Query

### Is Before `.isBefore(compared: Dayjs)`
### Is Before `.isBefore(compared: Dayjs, unit?: string)`

`Dayjs`가 다른 `Dayjs`보다 앞선 시점인지를 확인합니다. 반환 타입은 `boolean` 입니다.

```js
dayjs().isBefore(dayjs()); // false
dayjs().isBefore(dayjs(), 'year'); // false
```

### Is Same `.isSame(compared: Dayjs)`
### Is Same `.isSame(compared: Dayjs, unit?: string)`

`Dayjs`가 다른 `Dayjs`과 동일한 시점인지를 확인합니다. 반환 타입은 `boolean` 입니다.

```js
dayjs().isSame(dayjs()); // true
dayjs().isSame(dayjs(), 'year'); // true
```

### Is After `.isAfter(compared: Dayjs)`
### Is After `.isAfter(compared: Dayjs, unit?: string)`

`Dayjs`가 다른 `Dayjs`보다 뒷선 시점인지를 확인합니다. 반환 타입은 `boolean` 입니다.

```js
dayjs().isAfter(dayjs()); // false
dayjs().isAfter(dayjs(), 'year'); // false
```

### Is a Dayjs `.isDayjs(compared: any)`
Expand Down Expand Up @@ -435,6 +440,18 @@ plugin [`IsLeapYear`](./Plugin.md#isleapyear)

plugin [`WeekOfYear`](./Plugin.md#weekofyear)

### IsSameOrAfter

`.isSameOrAfter` to check if a date is same of after another date

plugin [`IsSameOrAfter`](./Plugin.md#issameorafter)

### IsSameOrBefore

`.isSameOrBefore` to check if a date is same of before another date.

plugin [`IsSameOrBefore`](./Plugin.md#issameorbefore)

### IsBetween

`.isBetween` to check if a date is between two other dates
Expand Down
Loading

0 comments on commit fd65464

Please sign in to comment.