كود :
<!DOCTYPE html>
<html dir="rtl" lang="ar">
<head>
<title> Daily Prayer Timetable </title>
<meta charset="utf-8">
<style>
body, td, th {font-family: verdana; font-size: 11px; color: #404040;}
#timetable {border-width: 1px; border-style: outset; border-collapse: collapse; border-color: gray; width: 10em;}
#timetable td, #timetable th {border-width: 1px; border-spacing: 1px; padding: 2px 4px; border-style: inset; border-color: #CCCCCC;}
#timetable th {color:black; text-align: center; font-weight: bold; background-color: #F8F7F4;}
</style>
</head>
<body>
<script type="text/javascript" src="../PrayTimes.js"></script>
<br>
<p align="center">saudia, ON, Riyadh<p>
<div align="center" id="table"></div>
<script type="text/javascript">
var date = new Date(); // today
var times = prayTimes.getTimes(date, [24.633333, 46.716667], 3);
var list = ['Fajr', 'Sunrise', 'Dhuhr', 'Asr', 'Maghrib', 'Isha', 'Midnight'];
const input = ['Fajr', 'banana', 'cherry'];
const replacements = {'Fajr':'الفجر','Sunrise':'الشروق','Dhuhr':'الظهر','Asr':'العصر','Maghrib':'المغرب','Isha':'العشاء' ,'Midnight':'منتصف الليل'};
const output = input.map(item => replacements[item] || item);
var html = '<table id="timetable">';
html += '<tr><th colspan="2">'+new Intl.DateTimeFormat('ar-EG-u-ca',{weekday:'long',day:'numeric',month:'long',year:'numeric',era:'short'}).formatToParts(date).filter(part=>part.type!=='era').map(part=>part.value).join('').trim()+'</th></tr>';
html += '<tr><th colspan="2">'+new Intl.DateTimeFormat('ar-SA-u-ca-islamic-umalqura',{weekday:'long',day:'numeric',month:'long',year:'numeric',era:'short'}).formatToParts(date).filter(part=>part.type!=='era').map(part=>part.value).join('').trim()+'</th></tr>';
for(var i in list) {
html += '<tr><td>'+ [list[i]].map(item => replacements[item] || item)[0]+ '</td>';
html += '<td>'+convertTo12Hour(times[list[i].toLowerCase()])+ '</td></tr>';
}
html += '</table>';
document.getElementById('table').innerHTML = html;
function convertTo12Hour(time24) {
let [hours, minutes] = time24.split(':');
hours = parseInt(hours);
minutes = parseInt(minutes);
const ampm = hours >= 12 ? 'م' : 'ص';
hours = hours % 12 || 12; // Convert "0" or "13-23" to 12-hour format
let ha=hours.toLocaleString("ar-SA");
let ma=minutes.toLocaleString("ar-SA");
return `${ha}:${ma} ${ampm}`;
}
</script>
</body>
</html>