Skip to content

Commit

Permalink
docs: Add Calendar plugin docs
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun committed Mar 29, 2019
1 parent d058f4a commit e925de6
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/en/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,3 +492,9 @@ plugin [`ToObject`](./Plugin.md#toobject)
`.min` `.max` to compare given dayjs instances

plugin [`MinMax`](./Plugin.md#minmax)

### Calendar

`.calendar` to display calendar time

plugin [`Calendar`](./Plugin.md#calendar)
20 changes: 20 additions & 0 deletions docs/en/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,26 @@ dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01'))
dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')])
```

### Calendar

- Calendar adds `.calendar` API to return a `string` to display calendar time

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

dayjs.extend(calendar)

dayjs().calendar(dayjs('2008-01-01'))
dayjs().calendar(null, {
sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM )
nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM )
nextWeek: 'dddd', // The next week ( Sunday at 2:30 AM )
lastDay: '[Yesterday]', // The day before ( Yesterday at 2:30 AM )
lastWeek: '[Last] dddd', // Last week ( Last Monday at 2:30 AM )
sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 )
})
```

## Customize

You could build your own Day.js plugin to meet different needs.
Expand Down
6 changes: 6 additions & 0 deletions docs/es-es/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,3 +492,9 @@ plugin [`ToObject`](./Plugin.md#toobject)
`.min` `.max` to compare given dayjs instances.

plugin [`MinMax`](./Plugin.md#minmax)

### Calendar

`.calendar` to display calendar time

plugin [`Calendar`](./Plugin.md#calendar)
20 changes: 20 additions & 0 deletions docs/es-es/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,26 @@ dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01'))
dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')])
```

### Calendar

- Calendar adds `.calendar` API to return a `string` to display calendar time

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

dayjs.extend(calendar)

dayjs().calendar(dayjs('2008-01-01'))
dayjs().calendar(null, {
sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM )
nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM )
nextWeek: 'dddd', // The next week ( Sunday at 2:30 AM )
lastDay: '[Yesterday]', // The day before ( Yesterday at 2:30 AM )
lastWeek: '[Last] dddd', // Last week ( Last Monday at 2:30 AM )
sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 )
})
```

## Personalización

Puedes construir tu propio complemento de Day.js para cubrir tus necesidades.
Expand Down
6 changes: 6 additions & 0 deletions docs/ja/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,3 +548,9 @@ plugin [`ToObject`](./Plugin.md#toobject)
`.min` `.max` to compare given dayjs instances.

plugin [`MinMax`](./Plugin.md#minmax)

### Calendar

`.calendar` to display calendar time

plugin [`Calendar`](./Plugin.md#calendar)
20 changes: 20 additions & 0 deletions docs/ja/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,26 @@ dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01'))
dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')])
```

### Calendar

- Calendar adds `.calendar` API to return a `string` to display calendar time

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

dayjs.extend(calendar)

dayjs().calendar(dayjs('2008-01-01'))
dayjs().calendar(null, {
sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM )
nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM )
nextWeek: 'dddd', // The next week ( Sunday at 2:30 AM )
lastDay: '[Yesterday]', // The day before ( Yesterday at 2:30 AM )
lastWeek: '[Last] dddd', // Last week ( Last Monday at 2:30 AM )
sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 )
})
```

## カスタマイズ

さまざまなニーズに合わせて独自の Day.js プラグインを構築することができます。
Expand Down
6 changes: 6 additions & 0 deletions docs/ko/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,9 @@ plugin [`ToObject`](./Plugin.md#toobject)
`.min` `.max` to compare given dayjs instances.

plugin [`MinMax`](./Plugin.md#minmax)

### Calendar

`.calendar` to display calendar time

plugin [`Calendar`](./Plugin.md#calendar)
20 changes: 20 additions & 0 deletions docs/ko/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,26 @@ dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01'))
dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')])
```

### Calendar

- Calendar adds `.calendar` API to return a `string` to display calendar time

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

dayjs.extend(calendar)

dayjs().calendar(dayjs('2008-01-01'))
dayjs().calendar(null, {
sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM )
nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM )
nextWeek: 'dddd', // The next week ( Sunday at 2:30 AM )
lastDay: '[Yesterday]', // The day before ( Yesterday at 2:30 AM )
lastWeek: '[Last] dddd', // Last week ( Last Monday at 2:30 AM )
sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 )
})
```

## Customize

다양한 요구를 충족하기위해 자신만의 Day.js 플러그인을 만들 수 있습니다.
Expand Down
6 changes: 6 additions & 0 deletions docs/pt-br/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,9 @@ plugin [`ToObject`](./Plugin.md#toobject)
`.min` `.max` to compare given dayjs instances.

plugin [`MinMax`](./Plugin.md#minmax)

### Calendar

`.calendar` to display calendar time

plugin [`Calendar`](./Plugin.md#calendar)
20 changes: 20 additions & 0 deletions docs/pt-br/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,26 @@ dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01'))
dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')])
```

### Calendar

- Calendar adds `.calendar` API to return a `string` to display calendar time

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

dayjs.extend(calendar)

dayjs().calendar(dayjs('2008-01-01'))
dayjs().calendar(null, {
sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM )
nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM )
nextWeek: 'dddd', // The next week ( Sunday at 2:30 AM )
lastDay: '[Yesterday]', // The day before ( Yesterday at 2:30 AM )
lastWeek: '[Last] dddd', // Last week ( Last Monday at 2:30 AM )
sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 )
})
```

## Customizar

Você também pode construir seu próprio plugin Day.js para diferentes necessidades.
Expand Down
6 changes: 6 additions & 0 deletions docs/zh-cn/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,3 +543,9 @@ plugin [`IsoWeeksInYear`](./Plugin.md#isoweeksinyear)
`.min` `.max` 比较传入的 dayjs 实例的大小

plugin [`MinMax`](./Plugin.md#minmax)

### 日历时间

`.calendar` 来显示日历时间

plugin [`Calendar`](./Plugin.md#calendar)
22 changes: 21 additions & 1 deletion docs/zh-cn/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ dayjs('2019-01-25').toObject()

### MinMax

- MinMax 增加了 `.min` `.max` API 返回一个 `dayjs` 来比较传入的 dayjs 实例的大小.
- MinMax 增加了 `.min` `.max` API 返回一个 `dayjs` 来比较传入的 dayjs 实例的大小

```javascript
import minMax from 'dayjs/plugin/minMax'
Expand All @@ -400,6 +400,26 @@ dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01'))
dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')])
```

### Calendar

- Calendar 增加了 `.calendar` API 返回一个 `string` 来显示日历时间。

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

dayjs.extend(calendar)

dayjs().calendar(dayjs('2008-01-01'))
dayjs().calendar(null, {
sameDay: '[今天] HH:mm', // 今天 ( 今天 2:30 AM )
nextDay: '[明天]', // 明天 ( 明天 2:30 AM )
nextWeek: '[下]dddd', // 下周 ( Sunday at 2:30 AM )
lastDay: '[昨天]', // 昨天 ( 昨天 2:30 AM )
lastWeek: '[上] dddd', // 上周 ( Last Monday at 2:30 AM )
sameElse: 'DD/MM/YYYY' // 其他情况 ( 7/10/2011 )
})
```

## 自定义

你可以根据需要自由的编写一个 Day.js 插件
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class Dayjs {
const arg = unit === C.D ? this.$D + (int - this.$W) : int

if (unit === C.M || unit === C.Y) {
// clone is for badMutable plugin
const date = this.clone().set(C.DATE, 1)
date.$d[name](arg)
date.init()
Expand Down

0 comments on commit e925de6

Please sign in to comment.