first commit

This commit is contained in:
2025-11-23 08:02:54 +01:00
commit afd3881015
52 changed files with 9280 additions and 0 deletions

View File

@ -0,0 +1,40 @@
import { NextResponse } from "next/server";
export interface SunTimes {
date: string;
sunrise: string;
sunset: string;
}
// Calcul approximatif du lever/coucher du soleil pour Fakarava
// Coordonnées de Fakarava (Rotoava) : -16.3167, -145.6167
// En production, utiliser une API comme https://sunrise-sunset.org/api
const calculateSunTimes = (date: Date, lat: number = -16.3167, lng: number = -145.6167): SunTimes => {
// Calcul simplifié (formule approximative)
const dayOfYear = Math.floor((date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000);
const declination = 23.45 * Math.sin((360 * (284 + dayOfYear) / 365) * Math.PI / 180);
const hourAngle = Math.acos(-Math.tan(lat * Math.PI / 180) * Math.tan(declination * Math.PI / 180)) * 180 / Math.PI;
const sunriseHour = 12 - hourAngle / 15 - (lng / 15);
const sunsetHour = 12 + hourAngle / 15 - (lng / 15);
const formatTime = (hour: number) => {
const h = Math.floor(hour);
const m = Math.floor((hour - h) * 60);
return `${h.toString().padStart(2, "0")}:${m.toString().padStart(2, "0")}`;
};
return {
date: date.toISOString().split("T")[0],
sunrise: formatTime(sunriseHour),
sunset: formatTime(sunsetHour),
};
};
export async function GET() {
const today = new Date();
const sunTimes = calculateSunTimes(today);
return NextResponse.json(sunTimes);
}