Skip to content

Commit a947a51

Browse files
myleshkMyles Fang
and
Myles Fang
authoredSep 21, 2023
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 <git@myles.hk>
1 parent c2ea004 commit a947a51

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed
 

‎src/locale/zh-hk.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ const locale = {
2222
L: 'YYYY/MM/DD',
2323
LL: 'YYYY年M月D日',
2424
LLL: 'YYYY年M月D日 HH:mm',
25-
LLLL: 'YYYY年M月D日dddd HH:mm'
25+
LLLL: 'YYYY年M月D日dddd HH:mm',
26+
l: 'YYYY/M/D',
27+
ll: 'YYYY年M月D日',
28+
lll: 'YYYY年M月D日 HH:mm',
29+
llll: 'YYYY年M月D日dddd HH:mm'
2630
},
2731
relativeTime: {
2832
future: '%s內',
@@ -38,6 +42,21 @@ const locale = {
3842
MM: '%d 個月',
3943
y: '一年',
4044
yy: '%d 年'
45+
},
46+
meridiem: (hour, minute) => {
47+
const hm = (hour * 100) + minute
48+
if (hm < 600) {
49+
return '凌晨'
50+
} else if (hm < 900) {
51+
return '早上'
52+
} else if (hm < 1100) {
53+
return '上午'
54+
} else if (hm < 1300) {
55+
return '中午'
56+
} else if (hm < 1800) {
57+
return '下午'
58+
}
59+
return '晚上'
4160
}
4261
}
4362

0 commit comments

Comments
 (0)
Please sign in to comment.