genel olarak yapılan düzeltmeler

This commit is contained in:
2026-07-29 04:17:22 +02:00
parent dc4af9cc1d
commit 579a51f899
4 changed files with 146 additions and 84 deletions
+38 -28
View File
@@ -1,23 +1,42 @@
const HIJRI_MONTHS = [
"Muharrem", "Safer", "Rebiülevvel", "Rebiülahir",
"Cemaziyelevvel", "Cemaziyelahir", "Receb", "Şaban",
"Ramazan", "Şevval", "Zilkade", "Zilhicce",
"Muharrem",
"Safer",
"Rebiülevvel",
"Rebiülahir",
"Cemaziyelevvel",
"Cemaziyelahir",
"Receb",
"Şaban",
"Ramazan",
"Şevval",
"Zilkade",
"Zilhicce",
];
const DAYS = [
"Pazar", "Pazartesi", "Salı", "Çarşamba",
"Perşembe", "Cuma", "Cumartesi",
"Pazar",
"Pazartesi",
"Salı",
"Çarşamba",
"Perşembe",
"Cuma",
"Cumartesi",
];
export function gregorianToHijri(date = new Date()) {
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
// Türkiye coğrafi hizalaması ve Hilal takvimi için +2 gün adjustment
const adjustment = 2;
const adjustedDate = new Date(
date.getTime() + adjustment * 24 * 60 * 60 * 1000,
);
const year = adjustedDate.getFullYear();
const month = adjustedDate.getMonth() + 1;
const day = adjustedDate.getDate();
let a = Math.floor((14 - month) / 12);
let y = year + 4800 - a;
let m = month + 12 * a - 3;
let jdn =
day +
Math.floor((153 * m + 2) / 5) +
@@ -38,6 +57,7 @@ export function gregorianToHijri(date = new Date()) {
Math.floor((30 - j) / 15) * Math.floor((17719 * j) / 50) -
Math.floor(j / 16) * Math.floor((15238 * j) / 43) +
29;
let hijriMonth = Math.floor((24 * l) / 709);
let hijriDay = l - Math.floor((709 * hijriMonth) / 24);
let hijriYear = 30 * n + j - 30;
@@ -73,27 +93,17 @@ export function calculateMissedPrayers(birthDate, gender, mukallafAge = 15) {
const diffTime = today - mukallafDate;
const days = Math.floor(diffTime / (1000 * 60 * 60 * 24));
return { fajr: days, dhuhr: days, asr: days, maghrib: days, isha: days, vitr: days, days };
return {
fajr: days,
dhuhr: days,
asr: days,
maghrib: days,
isha: days,
vitr: days,
days,
};
}
export function getHijriBirthDate(birthDate) {
return gregorianToHijri(new Date(birthDate));
}
export function getHijriAge(birthDate, mukallafAge = 15) {
const birth = new Date(birthDate);
const today = new Date();
const hijriBirth = gregorianToHijri(birth);
const hijriToday = gregorianToHijri(today);
let age = hijriToday.year - hijriBirth.year;
if (
hijriToday.month < hijriBirth.month ||
(hijriToday.month === hijriBirth.month && hijriToday.day < hijriBirth.day)
) {
age -= 1;
}
return Math.max(0, age);
}