Skip to content

Instantly share code, notes, and snippets.

@torchipeppo
Created September 11, 2025 16:38
Show Gist options
  • Select an option

  • Save torchipeppo/628d4b65160ac0f467c1aec521f6da4f to your computer and use it in GitHub Desktop.

Select an option

Save torchipeppo/628d4b65160ac0f467c1aec521f6da4f to your computer and use it in GitHub Desktop.
_get_full_moon_countdown_str() {
let today = new_midnight_date();
let lunar_calendar = JSON.parse(this.file_handler.get_file_text(this._get_fpath()));
// find the first full or new moon that is today or later,
// but also stop if today is any other "important" phase
// b/c that's a special message
let i = lunar_calendar.month_index[today.getMonth()];
while (true) {
let i_date = new_midnight_date(lunar_calendar.calendar[i][0]);
if (today.getTime() == i_date.getTime()) {
return CONSTANTS.MOON_PHASE_SHORTNAMES[lunar_calendar.calendar[i][1]];
}
if (today < i_date && (lunar_calendar.calendar[i][1] == "full" || lunar_calendar.calendar[i][1] == "new")) {
let days_left = Math.round((i_date - today) / (1000 * 60 * 60 * 24));
return SU.countdown_formatting(days_left);
}
i += 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment