genel olarak yapılan düzeltmeler
This commit is contained in:
@@ -1,13 +1,31 @@
|
||||
import { getCityByName } from "./locations.js";
|
||||
|
||||
export async function fetchPrayerTimes(cityName = "Edremit", lat, lon) {
|
||||
try {
|
||||
let url;
|
||||
if (lat !== undefined && lon !== undefined) {
|
||||
url = `https://api.aladhan.com/v1/timings?latitude=${encodeURIComponent(lat)}&longitude=${encodeURIComponent(lon)}&method=13`;
|
||||
} else {
|
||||
url = `https://api.aladhan.com/v1/timingsByCity?city=${encodeURIComponent(cityName)}&country=Turkey&method=13`;
|
||||
let fetchLat = lat;
|
||||
let fetchLon = lon;
|
||||
|
||||
// Eğer enlem/boylam verilmediyse şehir listemizden koordinatları çekiyoruz
|
||||
if (fetchLat === undefined || fetchLon === undefined) {
|
||||
const cityObj = getCityByName(cityName);
|
||||
if (cityObj) {
|
||||
fetchLat = cityObj.lat;
|
||||
fetchLon = cityObj.lon;
|
||||
}
|
||||
}
|
||||
|
||||
let url;
|
||||
if (fetchLat !== undefined && fetchLon !== undefined) {
|
||||
// Diyanet İşleri Başkanlığı Metodu = 13
|
||||
url = `https://api.aladhan.com/v1/timings?latitude=${fetchLat}&longitude=${fetchLon}&method=13`;
|
||||
} else {
|
||||
url = `https://api.aladhan.com/v1/timingsByCity?city=Edremit&country=Turkey&method=13`;
|
||||
}
|
||||
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) throw new Error("Namaz vakitleri alınamadı");
|
||||
if (!res.ok) {
|
||||
throw new Error("Namaz vakitleri alınamadı");
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
const t = data.data.timings;
|
||||
@@ -33,6 +51,7 @@ function getCurrentPrayer(timings) {
|
||||
const currentMinutes = now.getHours() * 60 + now.getMinutes();
|
||||
|
||||
const parseTime = (timeStr) => {
|
||||
if (!timeStr) return 0;
|
||||
const [h, m] = timeStr.split(":").map(Number);
|
||||
return h * 60 + m;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user