Debian Codegraph @

docs/islamic.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <title>islamic</title>
6
7 <meta name="color-scheme" content="light dark" />
8 <style>
9 li, p {text-align:justify}
10 ins {color:#00A000}
11 del {color:#A00000}
12 code {white-space:pre;}
13 @media (prefers-color-scheme: dark)
14 {
15 ins {color:#88FF88}
16 del {color:#FF5555}
17 }
18 </style>
19 </head>
20 <body>
21
22 <address align=right>
23 <br/>
24 <br/>
25 <a href="mailto:[email protected]">Howard E. Hinnant</a><br/>
26 2016-07-04<br/>
27 </address>
28 <hr/>
29 <h1 align=center><code>islamic</code></h1>
30
31 <h2>Contents</h2>
32
33 <ul>
34 <li><a href="https://github.com/HowardHinnant/date">github link</a></li>
35 <li><a href="#Introduction">Introduction</a></li>
36 </ul>
37
38 <a name="Introduction"></a><h2>Introduction</h2>
39
40 <p>
41 This is an Islamic calendar in the style of
42 <a href="date.html">date.h</a>.
43 Everything is the same here as for
44 <a href="date.html">date.h</a>,
45 except that the calendrical arithmetic implements a proleptic
46 <a href="https://en.wikipedia.org/wiki/Tabular_Islamic_calendar">Tabular Islamic calendar</a>.
47 </p>
48
49 <p>
50 The <code>islamic</code> calendar can interoperate with
51 <a href="date.html">date.h</a> and <a href="tz.html">tz.h</a> just by
52 paying attention to the namespace. For example to convert the <i>civil</i>
53 date <code>2016_y/jul/4</code> to an islamic date, just do:
54 </p>
55
56 <blockquote><pre>
57 #include "islamic.h"
58 #include &lt;iostream&gt;
59
60 int
61 main()
62 {
63 using namespace date::literals;
64 std::cout &lt;&lt; islamic::year_month_day{2016_y/jul/4} &lt;&lt; '\n';
65 }
66 </pre></blockquote>
67
68 <p>
69 This outputs:
70 </p>
71
72 <blockquote><pre>
73 1437-09-28
74 </pre></blockquote>
75
76 <p>
77 And here is the reverse conversion:
78 </p>
79
80 <blockquote><pre>
81 #include "islamic.h"
82 #include &lt;iostream&gt;
83
84 int
85 main()
86 {
87 using namespace islamic::literals;
88 std::cout &lt;&lt; date::year_month_day{1437_y/9/28} &lt;&lt; '\n';
89 }
90 </pre></blockquote>
91
92 <p>
93 Which outputs:
94 </p>
95
96 <blockquote><pre>
97 2016-07-04
98 </pre></blockquote>
99
100 <p>
101 You can even convert directly to the ISO-week-based calendar:
102 </p>
103
104 <blockquote><pre>
105 #include "islamic.h"
106 #include "iso_week.h"
107 #include &lt;iostream&gt;
108
109 int
110 main()
111 {
112 using namespace islamic::literals;
113 std::cout &lt;&lt; iso_week::year_weeknum_weekday{2016_y/jun/13} &lt;&lt; '\n';
114 }
115 </pre></blockquote>
116
117 <p>
118 Which outputs:
119 </p>
120
121 <blockquote><pre>
122 2016-W27-Mon
123 </pre></blockquote>
124
125 <p>
126
127 <p>
128 You can find the current local islamic date and time with:
129 </p>
130
131 <blockquote><pre>
132 #include "islamic.h"
133 #include "tz.h"
134 #include &lt;iostream&gt;
135
136 int
137 main()
138 {
139 auto zt = date::make_zoned(date::current_zone(), std::chrono::system_clock::now());
140 auto ld = date::floor&lt;date::days&gt;(zt.get_local_time());
141 islamic::year_month_day ymd{ld};
142 auto time = date::make_time(zt.get_local_time() - ld);
143 std::cout &lt;&lt; ymd &lt;&lt; ' ' &lt;&lt; time &lt;&lt; '\n';
144 }
145 </pre></blockquote>
146
147 <p>
148 Example output:
149 </p>
150
151 <blockquote><pre>
152 1437-09-28 16:24:56.578240
153 </pre></blockquote>
154
155 <p>
156 This calendar assumes that the Islamic day starts at midnight, like the civil
157 calendar. This is because the only thing that is customized to the Islamic
158 calendar is the calendar itself (days precision time keeping). For time-keeping
159 finer than days, the <code>&lt;chrono&gt;</code> library is still in use. The
160 Islamic calendar simply converts to and from <code>sys_days</code> (a
161 days-precision <code>std::chrono::time_point</code>) like every other calendar.
162 </p>
163
164 </body>
165 </html>