Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix leap year calculation formula #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions khayyam/algorithms_c.c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 return (a == 1 || a == 5 || a == 9 || a == 13 || a == 17 || a == 22 || a == 26 || a == 30)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

دمت گرم حالا چطوری مرجش کنیم؟

Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ static Error getJulianDayFromGregorianDate(int year, int month, int day, double


static Boolean isJalaliLeapYear(int year){
int a = mod(year - (year > 0 ? 474 : 473), 2820) + 474 + 38;
return mod(a * 682, 2816) < 682;
int a = mod(year, 33);
if (a == 1 || a == 5 || a == 9 || a == 13 || a == 17 || a == 22 || a == 26 || a == 30)
return true;
return false;
}


Expand Down
2 changes: 1 addition & 1 deletion khayyam/algorithms_pure.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_julian_day_from_gregorian_date(year, month, day):


def is_jalali_leap_year(year):
return ((((((year - [473, 474][year > 0]) % 2820) + 474) + 38) * 682) % 2816) < 682
return year % 33 in (1, 5, 9, 13, 17, 22, 26, 30)


def get_days_in_jalali_year(year):
Expand Down