Skip to content

Commit

Permalink
lunarTerms->years
Browse files Browse the repository at this point in the history
  • Loading branch information
gouguoyin committed Jan 26, 2024
1 parent 40632c8 commit 4c6bf62
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions calendar/lunar/lunar.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
"12-8": "腊八节",
}

lunarTerms = []int{
years = []int{
0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, // 1900-1909
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, // 1910-1919
0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, // 1920-1929
Expand Down Expand Up @@ -195,15 +195,15 @@ func (l Lunar) getOffsetInMonth() int {
func (l Lunar) getDaysInYear() int {
var days = 348
for i := 0x8000; i > 0x8; i >>= 1 {
if (lunarTerms[l.year-minYear] & i) != 0 {
if (years[l.year-minYear] & i) != 0 {
days++
}
}
return days + l.getDaysInLeapMonth()
}

func (l Lunar) getDaysInMonth() int {
if (lunarTerms[l.year-minYear] & (0x10000 >> uint(l.month))) != 0 {
if (years[l.year-minYear] & (0x10000 >> uint(l.month))) != 0 {
return 30
}
return 29
Expand All @@ -213,7 +213,7 @@ func (l Lunar) getDaysInLeapMonth() int {
if l.LeapMonth() == 0 {
return 0
}
if lunarTerms[l.year-minYear]&0x10000 != 0 {
if years[l.year-minYear]&0x10000 != 0 {
return 30
}
return 29
Expand Down Expand Up @@ -261,7 +261,7 @@ func (l Lunar) LeapMonth() int {
if l.Error != nil {
return 0
}
return lunarTerms[l.year-minYear] & 0xf
return years[l.year-minYear] & 0xf
}

// Day gets lunar day like 5.
Expand Down

0 comments on commit 4c6bf62

Please sign in to comment.