You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Not really the exact date, but it's ok for this example
float getExactDate(int year, int month, int day) {
boolean leapYear = false;
if (year % 400 == 0) {
leapYear = true;
}
else if (year % 100 == 0) {
leapYear = false;
}
else if (year % 4 == 0) {
leapYear = true;
}
if (leapYear) {
return year + (month + (day - 1f)/daysPerMonthLeapYear[month])/12f;
}
else {
return year + (month + (day - 1f)/daysPerMonth[month])/12f;
}
}
The problem is that the return values from the function lookup the month instead of month-1, which leads to grabbing an incorrect value from the lookups. This can be fixed with this change to the function:
// Not really the exact date, but it's ok for this example
float getExactDate(int year, int month, int day) {
boolean leapYear = false;
if (year % 400 == 0) {
leapYear = true;
}
else if (year % 100 == 0) {
leapYear = false;
}
else if (year % 4 == 0) {
leapYear = true;
}
if (leapYear) {
return year + (month + (day - 1f)/daysPerMonthLeapYear[month-1])/12f;
}
else {
return year + (month + (day - 1f)/daysPerMonth[month-1])/12f;
}
}
The text was updated successfully, but these errors were encountered:
Well... I see that the source data for the example has 0 as January... Anyhow, for anybody who finds this, if you are using 1 as january, then the fix I proposed addresses the issue.
The Oktoberfest example has this lookup:
and this function:
The problem is that the return values from the function lookup the
month
instead ofmonth-1
, which leads to grabbing an incorrect value from the lookups. This can be fixed with this change to the function:The text was updated successfully, but these errors were encountered: