diff --git a/docs/ja/Plugin.md b/docs/ja/Plugin.md index dadeb2d2..897493c3 100644 --- a/docs/ja/Plugin.md +++ b/docs/ja/Plugin.md @@ -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 プラグインを構築することができます。 diff --git a/docs/ko/Plugin.md b/docs/ko/Plugin.md index 64118ca9..504bb8ef 100644 --- a/docs/ko/Plugin.md +++ b/docs/ko/Plugin.md @@ -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 플러그인을 만들 수 있습니다. diff --git a/docs/pt-br/Plugin.md b/docs/pt-br/Plugin.md index 2ab777c2..b9f6c1cd 100644 --- a/docs/pt-br/Plugin.md +++ b/docs/pt-br/Plugin.md @@ -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. diff --git a/docs/zh-cn/Plugin.md b/docs/zh-cn/Plugin.md index 0dd04104..a83a9a6a 100644 --- a/docs/zh-cn/Plugin.md +++ b/docs/zh-cn/Plugin.md @@ -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插件 diff --git a/src/locale/id.js b/src/locale/id.js index da05f219..30d4cd7c 100644 --- a/src/locale/id.js +++ b/src/locale/id.js @@ -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}.` diff --git a/src/plugin/advancedFormat/index.js b/src/plugin/advancedFormat/index.js index 1af94b05..1557c76a 100644 --- a/src/plugin/advancedFormat/index.js +++ b/src/plugin/advancedFormat/index.js @@ -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) => { @@ -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) } } diff --git a/src/plugin/buddhistEra/index.js b/src/plugin/buddhistEra/index.js index 8f878e43..445e8df2 100644 --- a/src/plugin/buddhistEra/index.js +++ b/src/plugin/buddhistEra/index.js @@ -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) { @@ -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) } }