date/islamic.html
Andrea Pappacoda 8eeae97520 Support dark color-scheme
This patch updates the html documentation to add the color-scheme meta
element, signaling ligth and dark color scheme support, and updating the
inline CSS styles to override some colors when dark mode is active, to
make sure that the document is always readable.

I've also cleaned up a bit the CSS styles, but without functional
changes.
2024-09-28 16:39:58 -04:00

166 lines
3.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>islamic</title>
<meta name="color-scheme" content="light dark" />
<style>
li, p {text-align:justify}
ins {color:#00A000}
del {color:#A00000}
code {white-space:pre;}
@media (prefers-color-scheme: dark)
{
ins {color:#88FF88}
del {color:#FF5555}
}
</style>
</head>
<body>
<address align=right>
<br/>
<br/>
<a href="mailto:howard.hinnant@gmail.com">Howard E. Hinnant</a><br/>
2016-07-04<br/>
</address>
<hr/>
<h1 align=center><code>islamic</code></h1>
<h2>Contents</h2>
<ul>
<li><a href="https://github.com/HowardHinnant/date">github link</a></li>
<li><a href="#Introduction">Introduction</a></li>
</ul>
<a name="Introduction"></a><h2>Introduction</h2>
<p>
This is an Islamic calendar in the style of
<a href="date.html">date.h</a>.
Everything is the same here as for
<a href="date.html">date.h</a>,
except that the calendrical arithmetic implements a proleptic
<a href="https://en.wikipedia.org/wiki/Tabular_Islamic_calendar">Tabular Islamic calendar</a>.
</p>
<p>
The <code>islamic</code> calendar can interoperate with
<a href="date.html">date.h</a> and <a href="tz.html">tz.h</a> just by
paying attention to the namespace. For example to convert the <i>civil</i>
date <code>2016_y/jul/4</code> to an islamic date, just do:
</p>
<blockquote><pre>
#include "islamic.h"
#include &lt;iostream&gt;
int
main()
{
using namespace date::literals;
std::cout &lt;&lt; islamic::year_month_day{2016_y/jul/4} &lt;&lt; '\n';
}
</pre></blockquote>
<p>
This outputs:
</p>
<blockquote><pre>
1437-09-28
</pre></blockquote>
<p>
And here is the reverse conversion:
</p>
<blockquote><pre>
#include "islamic.h"
#include &lt;iostream&gt;
int
main()
{
using namespace islamic::literals;
std::cout &lt;&lt; date::year_month_day{1437_y/9/28} &lt;&lt; '\n';
}
</pre></blockquote>
<p>
Which outputs:
</p>
<blockquote><pre>
2016-07-04
</pre></blockquote>
<p>
You can even convert directly to the ISO-week-based calendar:
</p>
<blockquote><pre>
#include "islamic.h"
#include "iso_week.h"
#include &lt;iostream&gt;
int
main()
{
using namespace islamic::literals;
std::cout &lt;&lt; iso_week::year_weeknum_weekday{2016_y/jun/13} &lt;&lt; '\n';
}
</pre></blockquote>
<p>
Which outputs:
</p>
<blockquote><pre>
2016-W27-Mon
</pre></blockquote>
<p>
<p>
You can find the current local islamic date and time with:
</p>
<blockquote><pre>
#include "islamic.h"
#include "tz.h"
#include &lt;iostream&gt;
int
main()
{
auto zt = date::make_zoned(date::current_zone(), std::chrono::system_clock::now());
auto ld = date::floor&lt;date::days&gt;(zt.get_local_time());
islamic::year_month_day ymd{ld};
auto time = date::make_time(zt.get_local_time() - ld);
std::cout &lt;&lt; ymd &lt;&lt; ' ' &lt;&lt; time &lt;&lt; '\n';
}
</pre></blockquote>
<p>
Example output:
</p>
<blockquote><pre>
1437-09-28 16:24:56.578240
</pre></blockquote>
<p>
This calendar assumes that the Islamic day starts at midnight, like the civil
calendar. This is because the only thing that is customized to the Islamic
calendar is the calendar itself (days precision time keeping). For time-keeping
finer than days, the <code>&lt;chrono&gt;</code> library is still in use. The
Islamic calendar simply converts to and from <code>sys_days</code> (a
days-precision <code>std::chrono::time_point</code>) like every other calendar.
</p>
</body>
</html>