From a947a5171aad5695eaf593bc95fe073de0f0894a Mon Sep 17 00:00:00 2001 From: Myles Fang Date: Thu, 21 Sep 2023 22:23:35 +0800 Subject: [PATCH] fix: improve locale "zh-hk" format and meridiem (#2419) * feat: add more formats to locale "zh-hk" Ref: https://github.com/moment/moment/blob/develop/src/locale/zh-hk.js * feat: add missing meridiem to locale "zh-hk" * fix: fix lint error in locale "zh-hk" --------- Co-authored-by: Myles Fang --- src/locale/zh-hk.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/locale/zh-hk.js b/src/locale/zh-hk.js index 4aa47e7c4..193f2e2d8 100644 --- a/src/locale/zh-hk.js +++ b/src/locale/zh-hk.js @@ -22,7 +22,11 @@ const locale = { L: 'YYYY/MM/DD', LL: 'YYYY年M月D日', LLL: 'YYYY年M月D日 HH:mm', - LLLL: 'YYYY年M月D日dddd HH:mm' + LLLL: 'YYYY年M月D日dddd HH:mm', + l: 'YYYY/M/D', + ll: 'YYYY年M月D日', + lll: 'YYYY年M月D日 HH:mm', + llll: 'YYYY年M月D日dddd HH:mm' }, relativeTime: { future: '%s內', @@ -38,6 +42,21 @@ const locale = { MM: '%d 個月', y: '一年', yy: '%d 年' + }, + meridiem: (hour, minute) => { + const hm = (hour * 100) + minute + if (hm < 600) { + return '凌晨' + } else if (hm < 900) { + return '早上' + } else if (hm < 1100) { + return '上午' + } else if (hm < 1300) { + return '中午' + } else if (hm < 1800) { + return '下午' + } + return '晚上' } }