-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
While testing across multiple dates, I ran into this issue where the phases were in the previous month, including the next new moon. The bug is that the provided date is outside of the interval ranging from the previous new moon to the next new moon.
It can be replicated by trying the date July 6th, 2024, (2024-07-06):
const lune = require('lune');
const luxon = require('luxon');
const datetime = luxon.DateTime.fromISO("2024-07-06", { zone: "UTC" });
const jsdate = datetime.toJSDate();
lune.phase_hunt(jsdate);The output is here, you can see the dates are in June 2024 rather than in July 2024:

And when I try the next day over, 2024-07-07, it shows the phases in July 2024:
To work around this issue, in my code I added a conditional to check if the next new moon is before the provided date and if it is, to run the phase hunt 1 day in the future:
// my codebase is using Luxon
if (phases.nextnew_date.getTime() < date.getTime()) {
const futureDate = DateTime.fromJSDate(date).plus(Duration.fromObject({ days: 1 })).toJSDate();
phases = lune.phase_hunt(futureDate);
}
// without Luxon
if (phases.nextnew_date.getTime() < date.getTime()) {
const futureDate = new Date(date.getTime() + (1000 * 60 * 60 * 24));
phases = lune.phase_hunt(futureDate);
}Metadata
Metadata
Assignees
Labels
No labels
