Skip to content

Commit

Permalink
Merge pull request #151 from ZzqiZQute/master
Browse files Browse the repository at this point in the history
fix: 修改阴历日期判断逻辑
  • Loading branch information
wangxinleo authored Sep 12, 2022
2 parents d1d4a8e + 3814934 commit c9f849d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,13 @@ export const getBirthdayMessage = (festivals) => {
type = type.replace(/^\*/, '')
const [month, day] = date.split('-').map(Number)
// 获取今年的生日信息
const lunarInThisYear = Lunar.fromYmd((new Date).getFullYear(), month, day)
const solarInThisYear = lunarInThisYear.getSolar()
const thisYear = (new Date).getFullYear()
let lunarInThisYear = Lunar.fromYmd(thisYear, month, day)
let solarInThisYear = lunarInThisYear.getSolar()
if (solarInThisYear.getYear() > thisYear) {
lunarInThisYear = Lunar.fromYmd(thisYear - 1, month, day)
solarInThisYear = lunarInThisYear.getSolar()
}
const lunar = Lunar.fromYmd(Number(year), month, day)
const solar = lunar.getSolar()
return {
Expand Down

0 comments on commit c9f849d

Please sign in to comment.