1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
|
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="Start" href="index.html">
<link rel="previous" href="Date.html">
<link rel="next" href="Printer.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Time_Zone" rel="Chapter" href="Time_Zone.html">
<link title="Period" rel="Chapter" href="Period.html">
<link title="Time" rel="Chapter" href="Time.html">
<link title="Date" rel="Chapter" href="Date.html">
<link title="Calendar" rel="Chapter" href="Calendar.html">
<link title="Printer" rel="Chapter" href="Printer.html"><link title="Datatypes" rel="Section" href="#1_Datatypes">
<link title="Constructors" rel="Section" href="#1_Constructors">
<link title="Conversions" rel="Section" href="#1_Conversions">
<link title="Getters" rel="Section" href="#1_Getters">
<link title="Boolean operations on calendars" rel="Section" href="#1_Booleanoperationsoncalendars">
<link title="Coercions" rel="Section" href="#1_Coercions">
<link title="Period" rel="Section" href="#1_Period">
<link title="Arithmetic operations on calendars and periods" rel="Section" href="#1_Arithmeticoperationsoncalendarsandperiods">
<title>Calendar</title>
</head>
<body>
<div class="navbar"><a href="Date.html">Previous</a>
<a href="index.html">Up</a>
<a href="Printer.html">Next</a>
</div>
<center><h1>Module <a href="type_Calendar.html">Calendar</a></h1></center>
<br>
<pre><span class="keyword">module</span> Calendar: <code class="code">sig</code> <a href="Calendar.html">..</a> <code class="code">end</code></pre>Calendar operations.
<p>
This module combines the implementations on <code class="code">Date</code> and <code class="code">Time</code>.
So, a calendar is a 6-uple (year, month, day, hour, minute, second).
<p>
If you only need operations on dates, you should better use the module
<code class="code">Date</code>. But if you need to manage more precise date, use this module.
The exact Julian period is now
<code class="code">[January, 1st 4713 BC at midday GMT; January 22th, 3268 AC at midday GMT]</code>.
<p>
This module uses floating point arithmetics.
Then, egality over calendars may be erroneous (as egality over <code class="code">float</code>).
You should better use the <code class="code">equal</code> function defined in this module instead
of <code class="code">(=)</code>.<br>
<hr width="100%">
<br>
<a name="1_Datatypes"></a>
<h1>Datatypes</h1><br>
<pre><span class="keyword">type</span> <a name="TYPEt"></a><code class="type"></code>t </pre>
<div class="info">
Type of a date refined with a time, so called a calendar.<br>
</div>
<pre><span class="keyword">type</span> <a name="TYPEday"></a><code class="type"></code>day = <code class="type"><a href="Date.html#TYPEday">Date.day</a></code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Sun</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Mon</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Tue</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Wed</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Thu</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Fri</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Sat</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><code>Days of the week.</code></td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
<pre><span class="keyword">type</span> <a name="TYPEmonth"></a><code class="type"></code>month = <code class="type"><a href="Date.html#TYPEmonth">Date.month</a></code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Jan</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Feb</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Mar</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Apr</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">May</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Jun</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Jul</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Aug</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Sep</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Oct</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Nov</span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span class="constructor">Dec</span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><code>Months of the year.</code></td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
<pre><span class="keyword">type</span> <a name="TYPEyear"></a><code class="type"></code>year = <code class="type"><a href="Date.html#TYPEyear">Date.year</a></code> </pre>
<div class="info">
Year as an int<br>
</div>
<pre><span class="keyword">type</span> <a name="TYPEfield"></a><code class="type"></code>field = <code class="type">[ `Day | `Hour | `Minute | `Month | `Second | `Week | `Year ]</code> </pre>
<div class="info">
The different fields of a calendar.<br>
</div>
<br>
<a name="1_Constructors"></a>
<h1>Constructors</h1><br>
<pre><span class="keyword">val</span> <a name="VALmake"></a>make : <code class="type">int -> int -> int -> int -> int -> int -> <a href="Calendar.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">make year month day hour minute second</code> makes the calendar
"year-month-day; hour-minute-second".<br>
</div>
<pre><span class="keyword">val</span> <a name="VALlmake"></a>lmake : <code class="type">year:int -><br> ?month:int -><br> ?day:int -> ?hour:int -> ?minute:int -> ?second:int -> unit -> <a href="Calendar.html#TYPEt">t</a></code></pre><div class="info">
Labelled version of <code class="code">make</code>.
The default value of <code class="code">month</code> and <code class="code">day</code> (resp. of <code class="code">hour</code>, <code class="code">minute</code>
and <code class="code">second</code>) is <code class="code">1</code> (resp. <code class="code">0</code>).<br>
<b>Since</b> 1.05<br>
</div>
<pre><span class="keyword">val</span> <a name="VALcreate"></a>create : <code class="type"><a href="Date.html#TYPEt">Date.t</a> -> <a href="Time.html#TYPEt">Time.t</a> -> <a href="Calendar.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">create d t</code> creates a calendar from the given date and time.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALnow"></a>now : <code class="type">unit -> <a href="Calendar.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">now ()</code> returns the current date and time (in the current time zone).<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfrom_jd"></a>from_jd : <code class="type">float -> <a href="Calendar.html#TYPEt">t</a></code></pre><div class="info">
Return the Julian day.
More precise than <code class="code">Date.from_jd</code>: the fractional part represents the
time.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfrom_mjd"></a>from_mjd : <code class="type">float -> <a href="Calendar.html#TYPEt">t</a></code></pre><div class="info">
Return the Modified Julian day.
It is <code class="code">Julian day - 2 400 000.5</code> (more precise than <code class="code">Date.from_mjd</code>).<br>
</div>
<br>
<a name="1_Conversions"></a>
<h1>Conversions</h1><br>
<br>
Those functions have the same behaviour as those defined in <code class="code">Time</code>.<br>
<pre><span class="keyword">val</span> <a name="VALconvert"></a>convert : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> <a href="Time_Zone.html#TYPEt">Time_Zone.t</a> -> <a href="Time_Zone.html#TYPEt">Time_Zone.t</a> -> <a href="Calendar.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALto_gmt"></a>to_gmt : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> <a href="Calendar.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALfrom_gmt"></a>from_gmt : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> <a href="Calendar.html#TYPEt">t</a></code></pre><br>
<a name="1_Getters"></a>
<h1>Getters</h1><br>
<br>
Those functions have the same behavious as those defined in <code class="code">Date</code>.<br>
<pre><span class="keyword">val</span> <a name="VALdays_in_month"></a>days_in_month : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> int</code></pre><pre><span class="keyword">val</span> <a name="VALday_of_week"></a>day_of_week : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> <a href="Calendar.html#TYPEday">day</a></code></pre><pre><span class="keyword">val</span> <a name="VALday_of_month"></a>day_of_month : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> int</code></pre><pre><span class="keyword">val</span> <a name="VALday_of_year"></a>day_of_year : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> int</code></pre><pre><span class="keyword">val</span> <a name="VALweek"></a>week : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> int</code></pre><pre><span class="keyword">val</span> <a name="VALmonth"></a>month : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> <a href="Calendar.html#TYPEmonth">month</a></code></pre><pre><span class="keyword">val</span> <a name="VALyear"></a>year : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> int</code></pre><br>
<code class="code">to_jd</code> and <code class="code">to_mjd</code> are more precise than <code class="code">Date.to_jd</code> and
<code class="code">Date.to_mjd</code>.<br>
<pre><span class="keyword">val</span> <a name="VALto_jd"></a>to_jd : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> float</code></pre><pre><span class="keyword">val</span> <a name="VALto_mjd"></a>to_mjd : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> float</code></pre><br>
Those functions have the same behavious as those defined in <code class="code">Time</code>.<br>
<pre><span class="keyword">val</span> <a name="VALhour"></a>hour : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> int</code></pre><pre><span class="keyword">val</span> <a name="VALminute"></a>minute : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> int</code></pre><pre><span class="keyword">val</span> <a name="VALsecond"></a>second : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> int</code></pre><br>
<a name="1_Booleanoperationsoncalendars"></a>
<h1>Boolean operations on calendars</h1><br>
<pre><span class="keyword">val</span> <a name="VALequal"></a>equal : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> <a href="Calendar.html#TYPEt">t</a> -> bool</code></pre><div class="info">
Equality function between two calendars.
<code class="code">equal</code> should be used instead of <code class="code">(=)</code>.<br>
</div>
<br>
Those functions have the same behavious as those defined in <code class="code">Date</code>.<br>
<pre><span class="keyword">val</span> <a name="VALcompare"></a>compare : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> <a href="Calendar.html#TYPEt">t</a> -> int</code></pre><pre><span class="keyword">val</span> <a name="VALis_leap_day"></a>is_leap_day : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> bool</code></pre><pre><span class="keyword">val</span> <a name="VALis_gregorian"></a>is_gregorian : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> bool</code></pre><pre><span class="keyword">val</span> <a name="VALis_julian"></a>is_julian : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> bool</code></pre><br>
Those functions have the same behavious as those defined in <code class="code">Time</code>.<br>
<pre><span class="keyword">val</span> <a name="VALis_pm"></a>is_pm : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> bool</code></pre><pre><span class="keyword">val</span> <a name="VALis_am"></a>is_am : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> bool</code></pre><br>
<a name="1_Coercions"></a>
<h1>Coercions</h1><br>
<pre><span class="keyword">val</span> <a name="VALto_unixtm"></a>to_unixtm : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> Unix.tm</code></pre><div class="info">
Convert a calendar into the <code class="code">unix.tm</code> type.
The field <code class="code">isdst</code> is always <code class="code">false</code>. More precise than <code class="code">Date.to_unixtm</code>.<br>
<b>Since</b> 1.01<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfrom_unixtm"></a>from_unixtm : <code class="type">Unix.tm -> <a href="Calendar.html#TYPEt">t</a></code></pre><div class="info">
Inverse of <code class="code">to_unixtm</code>. Assumes the current time zone.
So, we have the following invariant:
<code class="code">hour (from_unixtm u) = u.Unix.tm_hour</code>.<br>
<b>Since</b> 1.01<br>
</div>
<pre><span class="keyword">val</span> <a name="VALto_unixfloat"></a>to_unixfloat : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> float</code></pre><div class="info">
Convert a calendar to a float such than
<code class="code">to_unixfloat (make 1970 1 1 0 0 0)</code> returns <code class="code">0.0</code> at UTC.
So such a float is convertible with those of the <code class="code">Unix</code> module.
More precise than <code class="code">Date.to_unixfloat</code>.<br>
<b>Since</b> 1.01<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfrom_unixfloat"></a>from_unixfloat : <code class="type">float -> <a href="Calendar.html#TYPEt">t</a></code></pre><div class="info">
Inverse of <code class="code">to_unixfloat</code>. Assumes the current time zone.
So, we have the following invariant:
<code class="code">hour (from_unixfloat u) = (Unix.gmtime u).Unix.tm_hour</code>.<br>
<b>Since</b> 1.01<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfrom_date"></a>from_date : <code class="type"><a href="Date.html#TYPEt">Date.t</a> -> <a href="Calendar.html#TYPEt">t</a></code></pre><div class="info">
Convert a date to a calendar.
The time is midnight in the current time zone.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALto_date"></a>to_date : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> <a href="Date.html#TYPEt">Date.t</a></code></pre><div class="info">
Convert a calendar to a date. Time part of the calendar is ignored.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALto_time"></a>to_time : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> <a href="Time.html#TYPEt">Time.t</a></code></pre><div class="info">
Convert a calendar to a time. Date part of the calendar is ignored.<br>
<b>Since</b> 1.03<br>
</div>
<br>
<a name="1_Period"></a>
<h1>Period</h1><br>
<pre><span class="keyword">module</span> <a href="Calendar.Period.html">Period</a>: <code class="code">sig</code> <a href="Calendar.Period.html">..</a> <code class="code">end</code></pre><br>
<a name="1_Arithmeticoperationsoncalendarsandperiods"></a>
<h1>Arithmetic operations on calendars and periods</h1><br>
<br>
Those functions have the same behavious as those defined in <code class="code">Date</code>.<br>
<pre><span class="keyword">val</span> <a name="VALadd"></a>add : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> Period.t -> <a href="Calendar.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALsub"></a>sub : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> <a href="Calendar.html#TYPEt">t</a> -> Period.t</code></pre><pre><span class="keyword">val</span> <a name="VALrem"></a>rem : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> Period.t -> <a href="Calendar.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALnext"></a>next : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> <a href="Calendar.html#TYPEfield">field</a> -> <a href="Calendar.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprev"></a>prev : <code class="type"><a href="Calendar.html#TYPEt">t</a> -> <a href="Calendar.html#TYPEfield">field</a> -> <a href="Calendar.html#TYPEt">t</a></code></pre></body></html>
|