Skip to content

Instantly share code, notes, and snippets.

@nadimattari
Created June 15, 2023 17:22
Show Gist options
  • Save nadimattari/ecd9ab477b6989c9a03e0508f2e95da0 to your computer and use it in GitHub Desktop.
Save nadimattari/ecd9ab477b6989c9a03e0508f2e95da0 to your computer and use it in GitHub Desktop.
Auqaat-us-Salah for dfferent locations in Mauritius
<?php
date_default_timezone_set('Indian/Mauritius');
$locations = [
"BEAU BASSIN " => ['lat' => -20.2264373, 'lng' => 57.4673638],
"BEL-AIR " => ['lat' => -20.2580237, 'lng' => 57.7496662],
"BRISSEE VERDIERE" => ['lat' => -20.1698149, 'lng' => 57.6551895],
"CAP MALHEUREUX " => ['lat' => -19.9923642, 'lng' => 57.613296],
"CHEMIN GRENIER " => ['lat' => -20.4813409, 'lng' => 57.4740681],
"CUREPIPE " => ['lat' => -20.3285089, 'lng' => 57.4871203],
"EBENE " => ['lat' => -20.2515978, 'lng' => 57.4979137],
"FLACQ " => ['lat' => -20.1898665, 'lng' => 57.6829116],
"GOODLANDS " => ['lat' => -20.0368736, 'lng' => 57.6503921],
"GRAND-BAY " => ['lat' => -20.0163716, 'lng' => 57.57836],
"L'ESCALIER " => ['lat' => -20.4783832, 'lng' => 57.615992],
"MAHEBOURG " => ['lat' => -20.4083799, 'lng' => 57.705411],
"MIDLANDS " => ['lat' => -20.3408195, 'lng' => 57.5659689],
"NEW GROVE " => ['lat' => -20.4110124, 'lng' => 57.6142965],
"PAMPLEMOUSSES " => ['lat' => -20.1123231, 'lng' => 57.5645785],
"PHOENIX " => ['lat' => -20.2932987, 'lng' => 57.5162614],
"PORT LOUIS " => ['lat' => -20.1597873, 'lng' => 57.5044822],
"Q. MILITAIRE " => ['lat' => -20.2465697, 'lng' => 57.596335],
"QUATRE BORNES " => ['lat' => -20.2719979, 'lng' => 57.4766351],
"RIV. D. REMPART " => ['lat' => -20.1084958, 'lng' => 57.6901616],
"ROSE HILL " => ['lat' => -20.2383065, 'lng' => 57.465141],
"ST PIERRE " => ['lat' => -20.2247459, 'lng' => 57.5367308],
"TERRE ROUGE " => ['lat' => -20.1270783, 'lng' => 57.5331549],
"TRIOLET " => ['lat' => -20.0656145, 'lng' => 57.5426681],
"VACOAS " => ['lat' => -20.3048464, 'lng' => 57.4739171],
"VALE (LOWER) " => ['lat' => -20.0301797, 'lng' => 57.5921825],
];
$tables = [
'astronomical_twilight_begin' => 'FAJR -18 ',
'sunrise' => 'SUNRISE ',
'dahwa-e-kubra' => 'DAHWA-e-KUBRA ',
'zawaal--zohr-starts' => 'ZOHR ',
'sunset' => 'MAGHRIB ',
'astronomical_twilight_end' => 'ESHA +18 ',
];
$headers['YEAR'] = implode(' | ', array_keys($locations));
$headers['----'] = implode(' | ', array_fill(0, count($locations), '----------------'));
$date = date('m-d'); // today "mm-dd"
$auqat = [];
for ($y = date('Y'); $y <= 2042; $y++) {
foreach($locations as $location => $coordinates) {
$sun_info = date_sun_info(
strtotime("{$y}-{$date}"),
$coordinates['lat'],
$coordinates['lng']
);
$sun_info['zawaal--zohr-starts'] = $sun_info['sunrise'] + ($sun_info['sunset'] - $sun_info['sunrise']) / 2;
$sun_info['dahwa-e-kubra'] = $sun_info['astronomical_twilight_begin'] + ($sun_info['sunset'] - $sun_info['astronomical_twilight_begin']) / 2;
foreach ($sun_info as $key => $val) {
$sun_info[$key] = date("H:i:s", (int)$val);
}
foreach($tables as $key => $title) {
$auqat[$title][$location][$y] = $sun_info[$key];
}
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Auqaat Mauritius</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
</head>
<body>
<div class="container-fluid text-cente">
<div class="row gx-5">
<div class="col">
<h1 class="display-1">
<?php echo date('d-F'); ?>
<small class="text-body-secondary">takreebi (approximate timings)</small>
</h1>
<p>
NOTE: Timings according to altitude is applied only for sunrise and sunset. In this exercise, no such formulae was applied.
</p>
<?php
foreach($auqat as $title => $details) {
echo '<h3 class="mark">' . $title . '</h3>';
$years = array_keys(array_values($details)[0]);
$years_header = array_map(function($el) {
return str_pad($el, 8, ' ', STR_PAD_BOTH);
}, $years);
echo '<pre class="font-monospace" style="font-size:0.8em">';
echo 'LOCATION | ' . implode(' | ', $years_header) . PHP_EOL;
echo '---------------- | ' . implode(' | ', array_fill(0, count($years), '--------')) . PHP_EOL;
foreach($details as $location => $year_timings) {
echo $location . ' | ' . implode(' | ', $year_timings) . PHP_EOL;
}
echo '</pre>';
}
?>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment