From 22680848da6e10eef868ae16d4a8e59009d789cf Mon Sep 17 00:00:00 2001 From: andrewhood125ruhuc Date: Mon, 24 Feb 2025 22:06:04 +0800 Subject: [PATCH 1/4] fix: fix id locale fix #234 --- src/locale/id.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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}.` From 2df6470386272ffdb5db6b2e5a7edc864844de95 Mon Sep 17 00:00:00 2001 From: andrewhood125ruhuc Date: Tue, 25 Feb 2025 10:21:24 +0800 Subject: [PATCH 2/4] chore: format no locale object --- src/plugin/advancedFormat/index.js | 4 ++-- src/plugin/buddhistEra/index.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugin/advancedFormat/index.js b/src/plugin/advancedFormat/index.js index 1af94b05..96d1b748 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) => { diff --git a/src/plugin/buddhistEra/index.js b/src/plugin/buddhistEra/index.js index 8f878e43..66d83b41 100644 --- a/src/plugin/buddhistEra/index.js +++ b/src/plugin/buddhistEra/index.js @@ -4,10 +4,10 @@ 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 locale = this.$locale() const str = formatStr || FORMAT_DEFAULT const result = str.replace(/BBBB|BB/g, (match) => { switch (match) { From a667df017027dfcf576d5f682c2257b409ef77e5 Mon Sep 17 00:00:00 2001 From: andrewhood125ruhuc Date: Wed, 26 Feb 2025 01:58:04 +0800 Subject: [PATCH 3/4] chore: update oldFormat --- src/plugin/advancedFormat/index.js | 2 +- src/plugin/buddhistEra/index.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugin/advancedFormat/index.js b/src/plugin/advancedFormat/index.js index 96d1b748..1557c76a 100644 --- a/src/plugin/advancedFormat/index.js +++ b/src/plugin/advancedFormat/index.js @@ -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 66d83b41..445e8df2 100644 --- a/src/plugin/buddhistEra/index.js +++ b/src/plugin/buddhistEra/index.js @@ -7,7 +7,6 @@ export default (o, c) => { // locale needed later proto.format = function (formatStr) { const yearBias = 543 const utils = this.$utils() - const locale = 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) } } From 3eec1adbcfd6a68949e2a1f0fbd02b62040c199f Mon Sep 17 00:00:00 2001 From: andrewhood125ruhuc Date: Sat, 1 Mar 2025 04:47:44 +0800 Subject: [PATCH 4/4] docs: update docs --- docs/ja/Plugin.md | 20 ++++++++++++++++++++ docs/ko/Plugin.md | 20 ++++++++++++++++++++ docs/pt-br/Plugin.md | 20 ++++++++++++++++++++ docs/zh-cn/Plugin.md | 20 ++++++++++++++++++++ 4 files changed, 80 insertions(+) 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插件