data = {
let acc = [];
for (const lat of lats) {
for (const lon of lons) {
let timeZone = getLocationTimeZone(lat, lon);
if (timeZone?.toString().startsWith("Antarctica/")) {
timeZone = undefined;
}
const sunrise = ss.getSunrise(lat, lon, date);
const sunset = ss.getSunset(lat, lon, date);
const tsunrise = Temporal.Instant.fromEpochMilliseconds(
sunrise.getTime()
);
const tsunset = Temporal.Instant.fromEpochMilliseconds(sunset.getTime());
const tyardstick = timeZone
? Temporal.ZonedDateTime.from({
timeZone,
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: 18
}).toInstant()
: undefined;
const tdurationSinceSunset = tyardstick
? tyardstick.since(tsunset)
: undefined;
let hoursSinceSunset = tdurationSinceSunset?.total({ unit: "hours" });
if (hoursSinceSunset < -10) {
hoursSinceSunset += 24;
}
acc.push({
lat,
lon,
timeZone,
sunrise,
sunset,
tyardstick,
yardstick: new Date(tyardstick?.epochMilliseconds),
tdurationSinceSunset,
hoursSinceSunset
});
}
}
return acc.filter(
(d) =>
!isNaN(d.sunset.getTime()) && !isNaN(d.sunrise.getTime()) && d.timeZone
);
}