Commit 1906d72d by caoyanzhi

fix: 修复农历显示异常的bug

parent 80ec8766
...@@ -223,7 +223,8 @@ export default { ...@@ -223,7 +223,8 @@ export default {
// date格式为 "2021年六月24 下午4:59:02" // date格式为 "2021年六月24 下午4:59:02"
const now = new Date().toLocaleString('zh-Hans-u-ca-chinese'); const now = new Date().toLocaleString('zh-Hans-u-ca-chinese');
// 解析date得到 六月廿四 的农历格式 // 解析date得到 六月廿四 的农历格式
const month = now.match(/年(.*)月/)[1]; let month = now.match(/年(.*)月/)[1];
month = month == '十一' ? '冬' : month;
let date = now.match(/月(\d*)\s/)[1]; let date = now.match(/月(\d*)\s/)[1];
if (Number(date) <= 10) { if (Number(date) <= 10) {
// 初几 // 初几
...@@ -233,7 +234,7 @@ export default { ...@@ -233,7 +234,7 @@ export default {
// 二十几 三十 // 二十几 三十
date = date[1] == 0 ? `${ones.charAt(date[0] - 1)}十` : `${tens.charAt(date[0] - 1)}${ones.charAt(date[1] - 1)}`; date = date[1] == 0 ? `${ones.charAt(date[0] - 1)}十` : `${tens.charAt(date[0] - 1)}${ones.charAt(date[1] - 1)}`;
} }
return `${month}${date}`; return `${month}${date}`;
}, },
/** /**
* 帮助中心跳转 * 帮助中心跳转
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment