Skip to content

Commit

Permalink
fix: conditional lunar leap month
Browse files Browse the repository at this point in the history
  • Loading branch information
kabeep committed Jan 6, 2025
1 parent fc7888a commit 5c1c3d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/helper/_internal/birthday-iterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function birthdayIterator(value: LunarDate, startYear: number, length: number) {
let year = startYear;
let index = length;
while (index-- && year++) {
const isLeapMonth = getLeapMonth(year) === value.month;
const isLeapMonth = value.isLeapMonth && getLeapMonth(year) === value.month;
const current = { ...value, year, isLeapMonth };
const date = toSolar(current);
if (date === -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/helper/get-now-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import ensure from './_internal/ensure';

function getNowDate(value: LunarDate): Date {
const year = new Date().getFullYear();
const isLeapYear = value.isLeapMonth && Boolean(getLeapMonth(year));
const solar = toSolar({ ...value, year, isLeapMonth: isLeapYear });
const isLeapMonth = value.isLeapMonth && getLeapMonth(year) === value.month;
const solar = toSolar({ ...value, year, isLeapMonth });
ensure(solar !== -1);
return solar;
}
Expand Down

0 comments on commit 5c1c3d4

Please sign in to comment.