Closed azoellner closed 9 months ago
Sometimes, a moon phase is skipped. This is caused by the phase float values of consecutive days skipping the according integer.
Note that here the int(phase) == 14 is skipped, hence code == 4 is missing.
int(phase) == 14
code == 4
This can be fixed by doing a code correction whenever the difference between today's and yesterday's code modulo 8 is larger than 1.
Suggested fix:
diff --git a/generate.py b/generate.py index daee891..16bddc0 100755 --- a/generate.py +++ b/generate.py @@ -56,14 +56,18 @@ def day_to_moon_phase_and_accurate_code(day): phase_today = phase(day) code_today = moon_phase_to_inacurate_code(phase_today) - if code_today % 2 != 0: - return phase_today, code_today - phase_yesterday = phase(day - timedelta(days=1)) code_yesterday = moon_phase_to_inacurate_code(phase_yesterday) + if (code_today - code_yesterday) % 8 > 1: + # skipped one code, hence do correction + return phase_today, (code_today - 1) % 8 + + if code_today % 2 != 0: + return phase_today, code_today + if code_today == code_yesterday: - return phase_today, code_today + 1 + return phase_today, (code_today + 1) % 8 return phase_today, code_today
P.S. Thank you for those nice calendars.
Thanks, fixed in https://github.com/PanderMusubi/lunar-phase-calendar/commit/c20a69a85e8e95676555e0b712370837232e66b8#diff-801d46835a8aee4eba56246cd21be7ae8628884a17b2648ec6afc8786e319af8
Sometimes, a moon phase is skipped. This is caused by the phase float values of consecutive days skipping the according integer.
Note that here the
int(phase) == 14
is skipped, hencecode == 4
is missing.This can be fixed by doing a code correction whenever the difference between today's and yesterday's code modulo 8 is larger than 1.
Suggested fix:
P.S. Thank you for those nice calendars.