From 7fff7bf15ba9f85e02ee2b03cf9a7da15230a7ab Mon Sep 17 00:00:00 2001 From: sight <26325820+Sight-wcg@users.noreply.github.com> Date: Fri, 11 Jul 2025 14:05:25 +0800 Subject: [PATCH] =?UTF-8?q?wip(i18n):=20=E6=94=B9=E8=BF=9B=20util.toDateSt?= =?UTF-8?q?ring=20meridiem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 遵循 CLDR day periods 标准 --- docs/i18n/detail/options.md | 8 ++++---- examples/i18n/zh-HK.js | 8 ++++---- src/modules/i18n.js | 9 +++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/i18n/detail/options.md b/docs/i18n/detail/options.md index caf61f9b..c6a23379 100644 --- a/docs/i18n/detail/options.md +++ b/docs/i18n/detail/options.md @@ -160,15 +160,15 @@ i18n.set({ toDateString: { meridiem: function(hours, minutes){ var hm = hours * 100 + minutes; - if (hm < 600) { + if (hm < 500) { return '凌晨'; - } else if (hm < 900) { + } else if (hm < 800) { return '早上'; - } else if (hm < 1100) { + } else if (hm < 1200) { return '上午'; } else if (hm < 1300) { return '中午'; - } else if (hm < 1800) { + } else if (hm < 1900) { return '下午'; } return '晚上'; diff --git a/examples/i18n/zh-HK.js b/examples/i18n/zh-HK.js index 4ff1fcf5..fa459585 100644 --- a/examples/i18n/zh-HK.js +++ b/examples/i18n/zh-HK.js @@ -159,15 +159,15 @@ export default { toDateString: { meridiem: function(hours, minutes){ var hm = hours * 100 + minutes; - if (hm < 600) { + if (hm < 500) { return '凌晨'; - } else if (hm < 900) { + } else if (hm < 800) { return '早上'; - } else if (hm < 1100) { + } else if (hm < 1200) { return '上午'; } else if (hm < 1300) { return '中午'; - } else if (hm < 1800) { + } else if (hm < 1900) { return '下午'; } return '晚上'; diff --git a/src/modules/i18n.js b/src/modules/i18n.js index 191e4ce5..cad72693 100644 --- a/src/modules/i18n.js +++ b/src/modules/i18n.js @@ -170,17 +170,18 @@ layui.define('lay', function(exports) { justNow: '刚刚' }, toDateString: { + // https://www.unicode.org/cldr/charts/47/supplemental/day_periods.html meridiem: function(hours, minutes){ var hm = hours * 100 + minutes; - if (hm < 600) { + if (hm < 500) { return '凌晨'; - } else if (hm < 900) { + } else if (hm < 800) { return '早上'; - } else if (hm < 1100) { + } else if (hm < 1200) { return '上午'; } else if (hm < 1300) { return '中午'; - } else if (hm < 1800) { + } else if (hm < 1900) { return '下午'; } return '晚上';