We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Consider interval of 2021-06-26, 2022-06-25. interval.getTotalMonths returns -1 instead of 11.
Here's my code fix it outside of datetime package.
@:access(datetime) class IntervalFix { public static function getTotalMonthsFix(interval:DateTimeIntervalCore) { final begin = interval.begin; final end = interval.end; var months = (end.getYear() - begin.getYear()) * 12 + (end.getMonth() - begin.getMonth()); var d1 = begin.getDay(); var d2 = end.getDay(); if (d2 < d1) { months --; } else if (d1 == d2) { var h1 = begin.getHour(); var h2 = end.getHour(); if (h2 < h1) { months --; } else if (h2 == h1) { var m1 = begin.getMinute(); var m2 = end.getMinute(); if (m2 < m1) { months --; } else if (m2 == m1 && end.getSecond() < begin.getSecond()) { months --; } } } return months; } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Consider interval of 2021-06-26, 2022-06-25. interval.getTotalMonths returns -1 instead of 11.
Here's my code fix it outside of datetime package.
The text was updated successfully, but these errors were encountered: