Skip to content

Commit

Permalink
Merge pull request #237 from iamkun/feature/iamkun
Browse files Browse the repository at this point in the history
update plugin && bugfix
  • Loading branch information
allmoviestvshowslistsfilmography28 committed Jun 11, 2018
2 parents 1aace46 + 1d451d5 commit d734b2c
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 12 deletions.
20 changes: 20 additions & 0 deletions docs/ja/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@ dayjs.extend(isLeapYear)
dayjs('2000-01-01').isLeapYear(); // true
```

### BuddhistEra
- BuddhistEra extends `dayjs().format` API to supply Buddhist Era (B.E.) format options.
- Buddhist Era is a year numbering system that primarily used in mainland Southeast Asian countries of Cambodia, Laos, Myanmar and Thailand as well as in Sri Lanka and Chinese populations of Malaysia and Singapore for religious or official occasions ([Wikipedia](https://en.wikipedia.org/wiki/Buddhist_calendar))
- To calculate BE year manually, just add 543 to year. For example 26 May 1977 AD/CE should display as 26 May 2520 BE (1977 + 543)

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

dayjs.extend(buddhistEra)

dayjs().format('BBBB BB')
```

List of added formats:

| Format | Output | Description |
| ------ | ---------------- | ------------------------------------- |
| `BBBB` | 2561 | Full BE Year (Year + 543) |
| `BB` | 61 | 2-digit of BE Year |

## カスタマイズ

さまざまなニーズに合わせて独自の Day.js プラグインを構築することができます。
Expand Down
20 changes: 20 additions & 0 deletions docs/ko/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,26 @@ dayjs.extend(isLeapYear)
dayjs('2000-01-01').isLeapYear(); // true
```

### BuddhistEra
- BuddhistEra extends `dayjs().format` API to supply Buddhist Era (B.E.) format options.
- Buddhist Era is a year numbering system that primarily used in mainland Southeast Asian countries of Cambodia, Laos, Myanmar and Thailand as well as in Sri Lanka and Chinese populations of Malaysia and Singapore for religious or official occasions ([Wikipedia](https://en.wikipedia.org/wiki/Buddhist_calendar))
- To calculate BE year manually, just add 543 to year. For example 26 May 1977 AD/CE should display as 26 May 2520 BE (1977 + 543)

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

dayjs.extend(buddhistEra)

dayjs().format('BBBB BB')
```

List of added formats:

| Format | Output | Description |
| ------ | ---------------- | ------------------------------------- |
| `BBBB` | 2561 | Full BE Year (Year + 543) |
| `BB` | 61 | 2-digit of BE Year |

## Customize

다양한 요구를 충족하기위해 자신만의 Day.js 플러그인을 만들 수 있습니다.
Expand Down
20 changes: 20 additions & 0 deletions docs/pt-br/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,26 @@ dayjs.extend(isLeapYear)
dayjs('2000-01-01').isLeapYear(); // true
```

### BuddhistEra
- BuddhistEra extends `dayjs().format` API to supply Buddhist Era (B.E.) format options.
- Buddhist Era is a year numbering system that primarily used in mainland Southeast Asian countries of Cambodia, Laos, Myanmar and Thailand as well as in Sri Lanka and Chinese populations of Malaysia and Singapore for religious or official occasions ([Wikipedia](https://en.wikipedia.org/wiki/Buddhist_calendar))
- To calculate BE year manually, just add 543 to year. For example 26 May 1977 AD/CE should display as 26 May 2520 BE (1977 + 543)

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

dayjs.extend(buddhistEra)

dayjs().format('BBBB BB')
```

List of added formats:

| Format | Output | Description |
| ------ | ---------------- | ------------------------------------- |
| `BBBB` | 2561 | Full BE Year (Year + 543) |
| `BB` | 61 | 2-digit of BE Year |

## Customizar

Você também pode construir seu próprio plugin Day.js para diferentes necessidades. Sinta-se à vontade para abrir um pull request e compartilhar seu plugin com a comunidade.
Expand Down
20 changes: 20 additions & 0 deletions docs/zh-cn/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,26 @@ dayjs.extend(isLeapYear)
dayjs('2000-01-01').isLeapYear(); // true
```

### 佛历
- BuddhistEra 扩展了 `dayjs().format` API 以支持佛历格式化.
- 佛教时代是一个年份编号系统,主要用于柬埔寨、老挝、缅甸和泰国等东南亚国家以及斯里兰卡、马来西亚和新加坡的中国人,用于宗教或官方场合([Wikipedia](https://en.wikipedia.org/wiki/Buddhist_calendar))
- 要计算BE年,只需在年份中添加543。 例如,1977年5月26日AD / CE应显示为2520年5月26日BE(1977 + 543)

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

dayjs.extend(buddhistEra)

dayjs().format('BBBB BB')
```

List of added formats:

| Format | Output | Description |
| ------ | ---------------- | ------------------------------------- |
| `BBBB` | 2561 | Full BE Year (Year + 543) |
| `BB` | 61 | 2-digit of BE Year |

## 自定义

你可以根据需要自由的编写一个Day.js插件
Expand Down
12 changes: 6 additions & 6 deletions src/locale/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ const locale = {
months: 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember'.split('_'),
relativeTime: {
future: 'dalam %s',
past: 'yang lalu %s',
past: '%s yang lalu',
s: 'beberapa detik',
m: 'satu menit',
m: 'semenit',
mm: '%d menit',
h: 'satu jam',
h: 'sejam',
hh: '%d jam',
d: 'satu hari',
d: 'sehari',
dd: '%d hari',
M: 'satu bulan',
M: 'sebulan',
MM: '%d bulan',
y: 'satu tahun',
y: 'setahun',
yy: '%d tahun'
},
ordinal: n => `${n}.`
Expand Down
6 changes: 3 additions & 3 deletions src/plugin/advancedFormat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default (o, c, d) => { // locale needed later
return `[${number}${(s[(v - 20) % 10] || s[v] || s[0])}]`
}
// extend en locale here
proto.format = function (formatStr, localeObject) {
const locale = localeObject || this.$locale()
proto.format = function (formatStr) {
const locale = this.$locale()
const utils = this.$utils()
const str = formatStr || FORMAT_DEFAULT
const result = str.replace(/Q|Do|X|x|k{1,2}|S/g, (match) => {
Expand All @@ -29,7 +29,7 @@ export default (o, c, d) => { // locale needed later
return this.$d.getTime()
}
})
return oldFormat.bind(this)(result, locale)
return oldFormat.bind(this)(result)
}
}

5 changes: 2 additions & 3 deletions src/plugin/buddhistEra/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ export default (o, c) => { // locale needed later
const proto = c.prototype
const oldFormat = proto.format
// extend en locale here
proto.format = function (formatStr, localeObject) {
proto.format = function (formatStr) {
const yearBias = 543
const utils = this.$utils()
const locale = localeObject || this.$locale()
const str = formatStr || FORMAT_DEFAULT
const result = str.replace(/BBBB|BB/g, (match) => {
switch (match) {
Expand All @@ -17,6 +16,6 @@ export default (o, c) => { // locale needed later
return utils.padStart(String(this.$y + yearBias), 4, '0')
}
})
return oldFormat.bind(this)(result, locale)
return oldFormat.bind(this)(result)
}
}

0 comments on commit d734b2c

Please sign in to comment.