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 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="next" href="Calendar_sig.S.Time.html">
<link rel="Up" href="Calendar_sig.S.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="Utils" rel="Chapter" href="Utils.html">
<link title="Time_Zone" rel="Chapter" href="Time_Zone.html">
<link title="Period" rel="Chapter" href="Period.html">
<link title="Time_sig" rel="Chapter" href="Time_sig.html">
<link title="Time" rel="Chapter" href="Time.html">
<link title="Ftime" rel="Chapter" href="Ftime.html">
<link title="Date_sig" rel="Chapter" href="Date_sig.html">
<link title="Date" rel="Chapter" href="Date.html">
<link title="Calendar_sig" rel="Chapter" href="Calendar_sig.html">
<link title="Calendar_builder" rel="Chapter" href="Calendar_builder.html">
<link title="Calendar" rel="Chapter" href="Calendar.html">
<link title="Fcalendar" rel="Chapter" href="Fcalendar.html">
<link title="Printer" rel="Chapter" href="Printer.html">
<link title="Version" rel="Chapter" href="Version.html"><link title="Datatypes" rel="Section" href="#2_Datatypes">
<link title="Exceptions" rel="Section" href="#2_Exceptions">
<link title="Constructors" rel="Section" href="#2_Constructors">
<link title="Getters" rel="Section" href="#2_Getters">
<link title="Dates are comparable" rel="Section" href="#2_Datesarecomparable">
<link title="Boolean operations on dates" rel="Section" href="#2_Booleanoperationsondates">
<link title="Coercions" rel="Section" href="#2_Coercions">
<link title="Period" rel="Section" href="#2_Period">
<link title="Arithmetic operations on dates and periods" rel="Section" href="#2_Arithmeticoperationsondatesandperiods">
<link title="Operations on years" rel="Section" href="#2_Operationsonyears">
<title>Calendar_sig.S.Date</title>
</head>
<body>
<div class="navbar"> <a href="Calendar_sig.S.html">Up</a>
<a href="Calendar_sig.S.Time.html">Next</a>
</div>
<center><h1>Module <a href="type_Calendar_sig.S.Date.html">Calendar_sig.S.Date</a></h1></center>
<br>
<pre><span class="keyword">module</span> Date: <code class="type"><a href="Date_sig.S.html">Date_sig.S</a></code><code class="type"> </code></pre>Date implementation used by this calendar.<br>
<b>Since</b> 2.0<br>
<hr width="100%">
<br>
<a name="2_Datatypes"></a>
<h2>Datatypes</h2><br>
<pre><span class="keyword">type</span> <a name="TYPEt"></a><code class="type"></code>t </pre>
<div class="info">
Type of a date.<br>
</div>
<br><code><span class="keyword">type</span> <a name="TYPEday"></a><code class="type"></code>day = </code><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>
</tr></table>
<div class="info">
Days of the week.<br>
</div>
<br><code><span class="keyword">type</span> <a name="TYPEmonth"></a><code class="type"></code>month = </code><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>
</tr></table>
<div class="info">
Months of the year.<br>
</div>
<pre><span class="keyword">type</span> <a name="TYPEyear"></a><code class="type"></code>year = <code class="type">int</code> </pre>
<div class="info">
Year as an <code class="code">int</code>.<br>
</div>
<pre><span class="keyword">type</span> <a name="TYPEfield"></a><code class="type"></code>field = <code class="type">[ `Day | `Month | `Week | `Year ]</code> </pre>
<div class="info">
The different fields of a date.<br>
</div>
<br>
<a name="2_Exceptions"></a>
<h2>Exceptions</h2><br>
<pre><span class="keyword">exception</span> <a name="EXCEPTIONOut_of_bounds"></a>Out_of_bounds</pre>
<div class="info">
Raised when a date is outside the Julian period.<br>
</div>
<pre><span class="keyword">exception</span> <a name="EXCEPTIONUndefined"></a>Undefined</pre>
<div class="info">
Raised when a date belongs to
<code class="code">[<span class="constructor">October</span> 5th, 1582; <span class="constructor">October</span> 14th, 1582]</code>.<br>
</div>
<br>
<a name="2_Constructors"></a>
<h2>Constructors</h2><br>
<pre><span class="keyword">val</span> <a name="VALmake"></a>make : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> int -> int -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">make year month day</code> makes the date year-month-day. A BC year <code class="code">y</code>
corresponds to the year <code class="code">-(y+1)</code>.<br>
<b>Raises</b><ul><li><code>Out_of_bounds</code> when a date is outside the Julian period.</li>
<li><code>Undefined</code> when a date belongs to <code class="code">[<span class="constructor">October</span> 5th, 1582; <span class="constructor">October</span>
14th, 1582]</code>.</li>
</ul>
<b>Example:</b> years (5 BC) and (1 BC) respectively correspond to years
(-4) and 0.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALlmake"></a>lmake : <code class="type">year:<a href="Date_sig.S.html#TYPEyear">year</a> -> ?month:int -> ?day:int -> unit -> <a href="Date_sig.S.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> is <code class="code">1</code>.<br>
<b>Since</b> 1.05<br>
<b>Raises</b><ul><li><code>Out_of_bounds</code> when a date is outside the Julian period.</li>
<li><code>Undefined</code> when a date belongs to <code class="code">[<span class="constructor">October</span> 5th, 1582; <span class="constructor">October</span>
14th, 1582]</code>.</li>
</ul>
</div>
<pre><span class="keyword">val</span> <a name="VALtoday"></a>today : <code class="type">unit -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Date of the current day (based on <code class="code"><span class="constructor">Time_Zone</span>.current ()</code>).<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfrom_jd"></a>from_jd : <code class="type">int -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Make a date from its Julian day.<br>
<b>Example:</b> <code class="code">from_jd 0</code> returns the date 4713 BC-1-1.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfrom_mjd"></a>from_mjd : <code class="type">int -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Make a date from its modified Julian day (i.e. Julian day - 2 400 001).
The Modified Julian day is more manageable than the Julian day.<br>
<b>Example:</b> <code class="code">from_mjd 0</code> returns the date 1858-11-17.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfrom_day_of_year"></a>from_day_of_year : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> int -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Make a date from a year and its day of the year.<br>
<b>Since</b> 2.0<br>
<b>Example:</b> <code class="code">from_day_of_year 2008 39</code> returns the date 2008-2-8.<br>
</div>
<br>
<a name="2_Getters"></a>
<h2>Getters</h2><br>
<pre><span class="keyword">val</span> <a name="VALdays_in_month"></a>days_in_month : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> int</code></pre><div class="info">
Number of days in the month of a date.<br>
<b>Example:</b> <code class="code">days_in_month (make 2003 6 26)</code> returns <code class="code">30</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALday_of_week"></a>day_of_week : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> <a href="Date_sig.S.html#TYPEday">day</a></code></pre><div class="info">
Day of the week.<br>
<b>Example:</b> <code class="code">day_of_week (make 2003 6 26)</code> returns <code class="code"><span class="constructor">Thu</span></code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALday_of_month"></a>day_of_month : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> int</code></pre><div class="info">
Day of the month.<br>
<b>Example:</b> <code class="code">day_of_month (make 2003 6 26)</code> returns <code class="code">26</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALday_of_year"></a>day_of_year : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> int</code></pre><div class="info">
Day of the year.<br>
<b>Examples:</b><ul><li><code class="code">day_of_year (make 2003 12 28)</code> returns <code class="code">362</code>.<br>
</li><li><code class="code">day_of_year (make 2003 1 5)</code> returns <code class="code">5</code><br>
</li></ul></div>
<pre><span class="keyword">val</span> <a name="VALweek"></a>week : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> int</code></pre><div class="info">
Week.<br>
<b>Examples:</b><ul><li><code class="code">week (make 2003 12 29)</code> returns <code class="code">1</code>.<br>
</li><li><code class="code">week (make 2003 12 28)</code> returns <code class="code">52</code>.<br>
</li><li><code class="code">week (make 2000 1 2)</code> returns <code class="code">52</code>.<br>
</li><li><code class="code">week (make 2000 1 3)</code> returns <code class="code">1</code>.<br>
</li></ul></div>
<pre><span class="keyword">val</span> <a name="VALmonth"></a>month : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> <a href="Date_sig.S.html#TYPEmonth">month</a></code></pre><div class="info">
Month.<br>
<b>Example:</b> <code class="code">month (make 2003 6 26)</code> returns <code class="code"><span class="constructor">Jun</span></code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALyear"></a>year : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> <a href="Date_sig.S.html#TYPEyear">year</a></code></pre><div class="info">
Year.<br>
<b>Example:</b> <code class="code">year (make 2003 6 26)</code> returns <code class="code">2003</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALto_jd"></a>to_jd : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> int</code></pre><div class="info">
Julian day.<br>
<b>Example:</b> <code class="code">to_jd (make (-4712) 1 1)</code> returns 0.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALto_mjd"></a>to_mjd : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> int</code></pre><div class="info">
Modified Julian day (i.e. Julian day - 2 400 001).
The Modified Julian day is more manageable than the Julian day.<br>
<b>Example:</b> <code class="code">to_mjd (make 1858 11 17)</code> returns 0.<br>
</div>
<br>
<a name="2_Datesarecomparable"></a>
<h2>Dates are comparable</h2><br>
<pre><span class="keyword">val</span> <a name="VALequal"></a>equal : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> <a href="Date_sig.S.html#TYPEt">t</a> -> bool</code></pre><div class="info">
Equality function between two dates.<br>
<b>Since</b> 1.09.0<br>
<b>See also</b> <a href="Utils.Comparable.html#VALequal">Utils.Comparable.equal</a><br>
</div>
<pre><span class="keyword">val</span> <a name="VALcompare"></a>compare : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> <a href="Date_sig.S.html#TYPEt">t</a> -> int</code></pre><div class="info">
Comparison function between two dates.<br>
<b>See also</b> <a href="Utils.Comparable.html#VALcompare">Utils.Comparable.compare</a><br>
</div>
<pre><span class="keyword">val</span> <a name="VALhash"></a>hash : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> int</code></pre><div class="info">
Hash function for dates.<br>
<b>Since</b> 2.0<br>
<b>See also</b> <a href="Utils.Comparable.html#VALhash">Utils.Comparable.hash</a><br>
</div>
<br>
<a name="2_Booleanoperationsondates"></a>
<h2>Boolean operations on dates</h2><br>
<pre><span class="keyword">val</span> <a name="VALis_valid_date"></a>is_valid_date : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> int -> int -> bool</code></pre><div class="info">
Check if a date is valid, that is the date has not been coerced to look
like a real date.<br>
<b>Since</b> 2.0<br>
<b>Examples:</b><ul><li><code class="code">is_valid_date 2008 2 30</code> returns <code class="code"><span class="keyword">false</span></code><br>
</li><li><code class="code">is_valid_date 2008 2 8</code> returns <code class="code"><span class="keyword">true</span></code><br>
</li></ul></div>
<pre><span class="keyword">val</span> <a name="VALis_leap_day"></a>is_leap_day : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> bool</code></pre><div class="info">
Return <code class="code"><span class="keyword">true</span></code> if a date is a leap day
(i.e. February, 24th of a leap year); <code class="code"><span class="keyword">false</span></code> otherwise.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALis_gregorian"></a>is_gregorian : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> bool</code></pre><div class="info">
Return <code class="code"><span class="keyword">true</span></code> if a date belongs to the Gregorian calendar;
<code class="code"><span class="keyword">false</span></code> otherwise.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALis_julian"></a>is_julian : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> bool</code></pre><div class="info">
Return <code class="code"><span class="keyword">true</span></code> iff a date belongs to the Julian calendar;
<code class="code"><span class="keyword">false</span></code> otherwise.<br>
</div>
<br>
<a name="2_Coercions"></a>
<h2>Coercions</h2><br>
<pre><span class="keyword">val</span> <a name="VALto_unixtm"></a>to_unixtm : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> Unix.tm</code></pre><div class="info">
Convert a date into the <code class="code"><span class="constructor">Unix</span>.tm</code> type.
The field <code class="code">is_isdst</code> is always <code class="code"><span class="keyword">false</span></code>. The fields <code class="code"><span class="constructor">Unix</span>.tm_sec</code>,
<code class="code"><span class="constructor">Unix</span>.tm_min</code> and <code class="code"><span class="constructor">Unix</span>.tm_hour</code> are irrelevant.<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="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Inverse of <code class="code">to_unixtm</code>. Assume the current time zone.<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="Date_sig.S.html#TYPEt">t</a> -> float</code></pre><div class="info">
Convert a date to a float such than <code class="code">to_unixfloat (make 1970 1 1)</code>
returns <code class="code">0.0</code>. So such a float is convertible with those of the <code class="code"><span class="constructor">Unix</span></code>
module. The fractional part of the result is always <code class="code">0</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="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Inverse of <code class="code">to_unixfloat</code>. Ignore the fractional part of the argument.
Assume the current time zone.<br>
<b>Since</b> 1.01<br>
</div>
<pre><span class="keyword">val</span> <a name="VALto_business"></a>to_business : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> <a href="Date_sig.S.html#TYPEyear">year</a> * int * <a href="Date_sig.S.html#TYPEday">day</a></code></pre><div class="info">
Return the "business week" and the day in this week respecting ISO 8601.
Notice that business weeks at the beginning and end of the year can
sometimes have year numbers which don't match the real year.<br>
<b>Since</b> 1.09.0<br>
<b>Examples:</b><ul><li><code class="code">to_business (make 2003 12 29)</code> returns <code class="code">2004, 1, <span class="constructor">Mon</span></code>.<br>
</li><li><code class="code">to_business (make 2003 12 28)</code> returns <code class="code">2003, 52, <span class="constructor">Sun</span></code><br>
</li><li><code class="code">to_business (make 2000 1 2)</code> returns <code class="code">1999, 52, <span class="constructor">Sun</span></code><br>
</li><li><code class="code">to_business (make 2000 1 3)</code> returns <code class="code">2000, 1, <span class="constructor">Mon</span></code><br>
</li></ul></div>
<pre><span class="keyword">val</span> <a name="VALfrom_business"></a>from_business : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> int -> <a href="Date_sig.S.html#TYPEday">day</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Inverse of <code class="code">to_business</code> respecting ISO-8601.
Notice that business weeks at the beginning and end of the year
can sometimes have year numbers which don't match the real year.<br>
<b>Since</b> 1.09.0<br>
<b>Raises</b> <code>Invalid_argument</code> if the date is bad.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALint_of_day"></a>int_of_day : <code class="type"><a href="Date_sig.S.html#TYPEday">day</a> -> int</code></pre><div class="info">
Convert a day to an integer respecting ISO-8601.
So, Monday is 1, Tuesday is 2, ..., and sunday is 7.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALday_of_int"></a>day_of_int : <code class="type">int -> <a href="Date_sig.S.html#TYPEday">day</a></code></pre><div class="info">
Inverse of <code class="code">int_of_day</code>.<br>
<b>Raises</b> <code>Invalid_argument</code> if the argument does not belong to <code class="code">1; 7</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALint_of_month"></a>int_of_month : <code class="type"><a href="Date_sig.S.html#TYPEmonth">month</a> -> int</code></pre><div class="info">
Convert a month to an integer respecting ISO-8601.
So, January is 1, February is 2 and so on.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmonth_of_int"></a>month_of_int : <code class="type">int -> <a href="Date_sig.S.html#TYPEmonth">month</a></code></pre><div class="info">
Inverse of <code class="code">int_of_month</code>.<br>
<b>Raises</b> <code>Invalid_argument</code> if the argument does not belong to <code class="code">1; 12</code>.<br>
</div>
<br>
<a name="2_Period"></a>
<h2>Period</h2><br>
<pre><span class="keyword">module</span> <a href="Date_sig.S.Period.html">Period</a>: <code class="code"><span class="keyword">sig</span></code> <a href="Date_sig.S.Period.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
A period is the number of days between two dates.
</div>
<br>
<a name="2_Arithmeticoperationsondatesandperiods"></a>
<h2>Arithmetic operations on dates and periods</h2><br>
<pre><span class="keyword">val</span> <a name="VALadd"></a>add : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> Period.t -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">add d p</code> returns <code class="code">d + p</code>.<br>
<b>Raises</b><ul><li><code>Out_of_bounds</code> when the resulting date is outside the Julian
period.</li>
<li><code>Undefined</code> when the resulting date belongs to <code class="code">[<span class="constructor">October</span> 5th,
1582; <span class="constructor">October</span> 14th, 1582]</code>.</li>
</ul>
<b>Examples:</b><ul><li><code class="code">add (make 2003 12 31) (<span class="constructor">Period</span>.month 2)</code> returns the date
2004-3-2 (following the coercion rule describes in the introduction).<br>
</li><li><code class="code">add (make 2003 12 31) (<span class="constructor">Period</span>.month 1)</code> returns the date
2004-1-31<br>
</li></ul></div>
<pre><span class="keyword">val</span> <a name="VALsub"></a>sub : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> <a href="Date_sig.S.html#TYPEt">t</a> -> Period.t</code></pre><div class="info">
<code class="code">sub d1 d2</code> returns the period between <code class="code">d1</code> and <code class="code">d2</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALrem"></a>rem : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> Period.t -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">rem d p</code> is equivalent to <code class="code">add d (<span class="constructor">Period</span>.opp p)</code>.<br>
<b>Raises</b><ul><li><code>Out_of_bounds</code> when the resulting date is outside the Julian
period.</li>
<li><code>Undefined</code> when the resulting date belongs to <code class="code">[<span class="constructor">October</span> 5th,
1582; <span class="constructor">October</span> 14th, 1582]</code>.</li>
</ul>
</div>
<pre><span class="keyword">val</span> <a name="VALnext"></a>next : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> <a href="Date_sig.S.html#TYPEfield">field</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">next d f</code> returns the date corresponding to the next specified field.<br>
<b>Raises</b><ul><li><code>Out_of_bounds</code> when the resulting date is outside the Julian
period.</li>
<li><code>Undefined</code> when the resulting date belongs to <code class="code">[<span class="constructor">October</span> 5th,
1582; <span class="constructor">October</span> 14th, 1582]</code>.</li>
</ul>
<b>Example:</b> <code class="code">next (make 2003 12 31) <span class="keywordsign">`</span><span class="constructor">Month</span></code> returns the date 2004-1-31
(i.e. one month later).<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprev"></a>prev : <code class="type"><a href="Date_sig.S.html#TYPEt">t</a> -> <a href="Date_sig.S.html#TYPEfield">field</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">prev d f</code> returns the date corresponding to the previous specified
field.<br>
<b>Raises</b><ul><li><code>Out_of_bounds</code> when the resulting date is outside the Julian
period.</li>
<li><code>Undefined</code> when the resulting date belongs to <code class="code">[<span class="constructor">October</span> 5th,
1582; <span class="constructor">October</span> 14th, 1582]</code>.</li>
</ul>
<b>Example:</b> <code class="code">prev (make 2003 12 31) <span class="keywordsign">`</span><span class="constructor">Year</span></code> returns the date 2002-12-31
(i.e. one year ago).<br>
</div>
<br>
<a name="2_Operationsonyears"></a>
<h2>Operations on years</h2><br>
<pre><span class="keyword">val</span> <a name="VALis_leap_year"></a>is_leap_year : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> bool</code></pre><div class="info">
Return <code class="code"><span class="keyword">true</span></code> if a year is a leap year; <code class="code"><span class="keyword">false</span></code> otherwise.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALsame_calendar"></a>same_calendar : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEyear">year</a> -> bool</code></pre><div class="info">
Return <code class="code"><span class="keyword">true</span></code> if two years have the same calendar; <code class="code"><span class="keyword">false</span></code>
otherwise.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALdays_in_year"></a>days_in_year : <code class="type">?month:<a href="Date_sig.S.html#TYPEmonth">month</a> -> <a href="Date_sig.S.html#TYPEyear">year</a> -> int</code></pre><div class="info">
Number of days in a year.
<p>
<code class="code">days_in_year ~month y</code> returns the number of days in the year <code class="code">y</code> up
to the end of the given month. Thus <code class="code">days_in_year ~month:<span class="constructor">Dec</span> y</code> is the
same as <code class="code">days_in_year y</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALweeks_in_year"></a>weeks_in_year : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> int</code></pre><div class="info">
Number of weeks in a year.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALweek_first_last"></a>week_first_last : <code class="type">int -> <a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a> * <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Return the first and last days of a week in a year.<br>
<b>Since</b> 1.08<br>
</div>
<pre><span class="keyword">val</span> <a name="VALnth_weekday_of_month"></a>nth_weekday_of_month : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEmonth">month</a> -> <a href="Date_sig.S.html#TYPEday">day</a> -> int -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">nth_weekday_of_month y m d n</code> returns the <code class="code">n</code>-th day <code class="code">d</code> in the month
<code class="code">m</code> of the year <code class="code">y</code> (for instance the 3rd Thursday of the month).<br>
<b>Since</b> 1.09.0<br>
</div>
<pre><span class="keyword">val</span> <a name="VALcentury"></a>century : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> int</code></pre><div class="info">
Century of a year.<br>
<b>Examples:</b><ul><li><code class="code">century 2001</code> returns 21.<br>
</li><li><code class="code">century 2000</code> returns 20<br>
</li></ul></div>
<pre><span class="keyword">val</span> <a name="VALmillenium"></a>millenium : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> int</code></pre><div class="info">
Millenium of a year.<br>
<b>Examples:</b><ul><li><code class="code">millenium 2001</code> returns 3.<br>
</li><li><code class="code">millenium 2000</code> returns 2<br>
</li></ul></div>
<pre><span class="keyword">val</span> <a name="VALsolar_number"></a>solar_number : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> int</code></pre><div class="info">
Solar number.
<p>
In the Julian calendar there is a one-to-one relationship between the
Solar number and the day on which a particular date falls.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALindiction"></a>indiction : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> int</code></pre><div class="info">
Indiction.
<p>
The Indiction was used in the middle ages to specify the position of a
year in a 15 year taxation cycle. It was introduced by emperor
Constantine the Great on 1 September 312 and ceased to be used in
1806.
<p>
The Indiction has no astronomical significance.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALgolden_number"></a>golden_number : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> int</code></pre><div class="info">
Golden number.
<p>
Considering that the relationship between the moon's phases and the
days of the year repeats itself every 19 years, it is natural to
associate a number between 1 and 19 with each year.
This number is the so-called Golden number.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALepact"></a>epact : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> int</code></pre><div class="info">
Epact.
<p>
The Epact is a measure of the age of the moon (i.e. the number of days
that have passed since an "official" new moon) on a particular date.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALeaster"></a>easter : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Easter Sunday.
<p>
In the Christian world, Easter (and the days immediately preceding it)
is the celebration of the death and resurrection of Jesus in
(approximately) AD 30.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALcarnaval"></a>carnaval : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Carnaval Monday. <code class="code">carnaval y</code> is <code class="code">easter y - 48</code>.<br>
<b>Since</b> 1.09.0<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmardi_gras"></a>mardi_gras : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Mardi Gras. <code class="code">mardi_gras y</code> is <code class="code">easter y - 47</code>.<br>
<b>Since</b> 1.09.0<br>
</div>
<pre><span class="keyword">val</span> <a name="VALash"></a>ash : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Ash Wednesday. <code class="code">ash y</code> is <code class="code">easter y - 46</code>.<br>
<b>Since</b> 1.09.0<br>
</div>
<pre><span class="keyword">val</span> <a name="VALpalm"></a>palm : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Palm Sunday. <code class="code">palm y</code> is <code class="code">easter y - 7</code>.<br>
<b>Since</b> 1.09.0<br>
</div>
<pre><span class="keyword">val</span> <a name="VALeaster_friday"></a>easter_friday : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Easter Friday. <code class="code">easter_friday y</code> is <code class="code">easter y - 2</code>.<br>
<b>Since</b> 1.09.0<br>
</div>
<pre><span class="keyword">val</span> <a name="VALeaster_saturday"></a>easter_saturday : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Easter Saturday. <code class="code">easter_saturday y</code> is <code class="code">easter y - 1</code>.<br>
<b>Since</b> 1.09.0<br>
</div>
<pre><span class="keyword">val</span> <a name="VALeaster_monday"></a>easter_monday : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Easter Monday. <code class="code">easter_monday y</code> is <code class="code">easter y + 1</code>.<br>
<b>Since</b> 1.09.0<br>
</div>
<pre><span class="keyword">val</span> <a name="VALascension"></a>ascension : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Ascension. <code class="code">ascension y</code> is <code class="code">easter y + 39</code>.<br>
<b>Since</b> 1.09.0<br>
</div>
<pre><span class="keyword">val</span> <a name="VALwithsunday"></a>withsunday : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Withsunday. <code class="code">withsunday y</code> is <code class="code">easter y + 49</code>.<br>
<b>Since</b> 1.09.0<br>
</div>
<pre><span class="keyword">val</span> <a name="VALwithmonday"></a>withmonday : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Withmonday. <code class="code">withmonday y</code> is <code class="code">easter y + 50</code>.<br>
<b>Since</b> 1.09.0<br>
</div>
<pre><span class="keyword">val</span> <a name="VALcorpus_christi"></a>corpus_christi : <code class="type"><a href="Date_sig.S.html#TYPEyear">year</a> -> <a href="Date_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Feast of Corpus Christi. <code class="code">corpus_christi y</code> is <code class="code">easter + 60</code>.<br>
<b>Since</b> 1.09.0<br>
</div>
</body></html>
|