Skip to content

Commit

Permalink
fix: improve locale "zh-hk" format and meridiem (#2419)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
myleshk and Myles Fang committed Sep 21, 2023
1 parent c2ea004 commit a947a51
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/locale/zh-hk.js
Expand Up @@ -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內',
Expand All @@ -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 '晚上'
}
}

Expand Down

0 comments on commit a947a51

Please sign in to comment.