Repository navigation
fix(lunar): don't report festivals on leap month days - #405
Merged
gouguoyin merged 1 commit intoNov 20, 2026
Merged
Conversation
Festival() looked up month-day only, so a leap month with the same number as a festival month got the festival a second time (闰五月初五 → 端午节). Festivals are in the regular month only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lunar.Festival()looks up onlymonth-day, so in a year whose leap month has the same number as a festival month, the festival is reported twice: once in the regular month and again in the leap month.Between 1990 and 2040 this hits 15 days (端午节 in 1990, 1998, 2009, 2028, 2039; 七夕节 + 中元节 in 2006, ...). Traditional festivals are kept in the regular month only.
Change
Festival()returns""whenisLeapMonthis true. Regular months are unchanged.Tests
New
leap monthsubtest inTestLunar_Festival: the regular-month day still has the festival, the leap-month day with the same number has none (2023 闰二月, 1995 闰八月, 2006 闰七月, 2028 闰五月, plusNewLunar(2023, 2, 2, true)). The leap-month asserts fail on master and pass here.go test -race ./...,go vet ./...and gofmt are clean.This doesn't touch the lunar data table, so it doesn't conflict with #404.