summaryrefslogtreecommitdiff
path: root/doc/Calendar_sig.S.Time.html
blob: 070edc2544338457d4520ab164257c70481f48ae (plain)
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
<!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="previous" href="Calendar_sig.S.Date.html">
<link rel="next" href="Calendar_sig.S.Period.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="Second" rel="Section" href="#2_Second">
<link title="Constructors" rel="Section" href="#2_Constructors">
<link title="Conversions" rel="Section" href="#2_Conversions">
<link title="Getters" rel="Section" href="#2_Getters">
<link title="Times are comparable" rel="Section" href="#2_Timesarecomparable">
<link title="Boolean operations on times" rel="Section" href="#2_Booleanoperationsontimes">
<link title="Coercions" rel="Section" href="#2_Coercions">
<link title="Period" rel="Section" href="#2_Period">
<link title="Arithmetic operations on times and periods" rel="Section" href="#2_Arithmeticoperationsontimesandperiods">
<title>Calendar_sig.S.Time</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Calendar_sig.S.Date.html" title="Calendar_sig.S.Date">Previous</a>
&nbsp;<a class="up" href="Calendar_sig.S.html" title="Calendar_sig.S">Up</a>
&nbsp;<a class="post" href="Calendar_sig.S.Period.html" title="Calendar_sig.S.Period">Next</a>
</div>
<h1>Module <a href="type_Calendar_sig.S.Time.html">Calendar_sig.S.Time</a></h1>
<pre><span class="keyword">module</span> Time: <code class="type"><a href="Time_sig.S.html">Time_sig.S</a></code><code class="type"> </code></pre><div class="info">
Time implementation used by this calendar.<br>
<b>Since</b> 2.0<br>
</div>
<hr width="100%">
<br>
<h2 id="2_Datatypes">Datatypes</h2><br>
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> </pre>
<div class="info">
Type of a time.<br>
</div>

<pre><span id="TYPEfield"><span class="keyword">type</span> <code class="type"></code>field</span> = <code class="type">[ `Hour | `Minute | `Second ]</code> </pre>
<div class="info">
The different fields of a time.<br>
</div>

<br>
<h2 id="2_Second">Second</h2><br>
<pre><span id="TYPEsecond"><span class="keyword">type</span> <code class="type"></code>second</span> </pre>
<div class="info">
Type of a second.<br>
<b>Since</b> 2.0 (was an integer in previous versions).<br>
</div>

<pre><span class="keyword">module</span> <a href="Time_sig.S.Second.html">Second</a>: <code class="type"><a href="Time_sig.Second.html">Time_sig.Second</a></code><code class="type">  with type t = second</code></pre><div class="info">
Second implementation
</div>
<br>
<h2 id="2_Constructors">Constructors</h2><br>
<pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type">int -> int -> <a href="Time_sig.S.html#TYPEsecond">second</a> -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">make hour minute second</code> makes the time hour-minute-second.<br>
</div>
<pre><span id="VALlmake"><span class="keyword">val</span> lmake</span> : <code class="type">?hour:int -> ?minute:int -> ?second:<a href="Time_sig.S.html#TYPEsecond">second</a> -> unit -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Labelled version of <code class="code">make</code>. The default value is <code class="code">0</code> for each argument.<br>
<b>Since</b> 1.05<br>
</div>
<pre><span id="VALnow"><span class="keyword">val</span> now</span> : <code class="type">unit -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
The current time based on <code class="code"><span class="constructor">Time_Zone</span>.current ()</code>.<br>
</div>
<pre><span id="VALmidnight"><span class="keyword">val</span> midnight</span> : <code class="type">unit -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">midnight ()</code> is midnight (expressed in the current time zone).
	So, it has always the same behaviour as <code class="code">make 0 0 0</code>.<br>
</div>
<pre><span id="VALmidday"><span class="keyword">val</span> midday</span> : <code class="type">unit -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">midday ()</code> is midday (expressed in the current time zone).
	So, it has always the same behaviour as <code class="code">make 12 0 0</code>.<br>
</div>
<br>
<h2 id="2_Conversions">Conversions</h2><br>
<pre><span id="VALconvert"><span class="keyword">val</span> convert</span> : <code class="type"><a href="Time_sig.S.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="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">convert t t1 t2</code> converts the time <code class="code">t</code> expressed in the time zone <code class="code">t1</code>
	to the same time expressed in the time zone <code class="code">t2</code>.<br>
<b>Example:</b> <code class="code">convert (make 20 0 0) (<span class="constructor">Time_Zone</span>.<span class="constructor">GMT_Plus</span> 2)
	(<span class="constructor">Time_Zone</span>.<span class="constructor">GMT_Plus</span> 4)</code> returns the time 22-0-0.<br>
</div>
<pre><span id="VALfrom_gmt"><span class="keyword">val</span> from_gmt</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">from_gmt t</code> is equivalent to
	<code class="code">convert t <span class="constructor">Time_Zone</span>.<span class="constructor">GMT</span> (<span class="constructor">Time_Zone</span>.current ())</code>.<br>
</div>
<pre><span id="VALto_gmt"><span class="keyword">val</span> to_gmt</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">to_gmt t</code> is equivalent to
	<code class="code">convert t (<span class="constructor">Time_Zone</span>.current ()) <span class="constructor">Time_Zone</span>.<span class="constructor">GMT</span></code>.<br>
</div>
<pre><span id="VALnormalize"><span class="keyword">val</span> normalize</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> <a href="Time_sig.S.html#TYPEt">t</a> * int</code></pre><div class="info">
<code class="code">normalize t</code> returns <code class="code">t</code> such that <code class="code">hour t</code> belongs to <code class="code">[0; 24[</code>. The
	second component of the result is the number of days needed by the
	modification.<br>
<b>Example:</b> <code class="code">normalize (make 22 0 0)</code> returns the time 22-0-0 and 0,
	<code class="code">normalize (make 73 0 0)</code> returns the time 1-0-0 and 3 and <code class="code">normalize
	(make (-73) 0 0)</code> returns the time 23-0-0 and (-4).<br>
</div>
<br>
<h2 id="2_Getters">Getters</h2><br>
<pre><span id="VALhour"><span class="keyword">val</span> hour</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> int</code></pre><div class="info">
Hour.<br>
<b>Example:</b> <code class="code">hour (make 20 0 0)</code> returns 20.<br>
</div>
<pre><span id="VALminute"><span class="keyword">val</span> minute</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> int</code></pre><div class="info">
Minute.<br>
<b>Example:</b> <code class="code">minute (make 20 10 0)</code> returns 10.<br>
</div>
<pre><span id="VALsecond"><span class="keyword">val</span> second</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> <a href="Time_sig.S.html#TYPEsecond">second</a></code></pre><div class="info">
Second.<br>
<b>Example:</b> <code class="code">second (make 20 10 5)</code> returns 5.<br>
</div>
<pre><span id="VALto_seconds"><span class="keyword">val</span> to_seconds</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> <a href="Time_sig.S.html#TYPEsecond">second</a></code></pre><div class="info">
Number of seconds of a time.<br>
<b>Example:</b> <code class="code">to_seconds (make 1 2 3)</code> returns <code class="code">3600 + 120 + 3 = 3723</code>.<br>
</div>
<pre><span id="VALto_minutes"><span class="keyword">val</span> to_minutes</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> float</code></pre><div class="info">
Number of minutes of a time. The resulting fractional part represents
	seconds.<br>
<b>Example:</b> <code class="code">to_minutes (make 1 2 3)</code> returns <code class="code">60+2+0.05 = 62.05</code>.<br>
</div>
<pre><span id="VALto_hours"><span class="keyword">val</span> to_hours</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> float</code></pre><div class="info">
Number of hours of a time. The resulting fractional part represents
	minutes and seconds.<br>
<b>Example:</b> <code class="code">to_hours (make 1 3 0)</code> returns <code class="code">1 + 0.05 = 1.05</code>.<br>
</div>
<br>
<h2 id="2_Timesarecomparable">Times are comparable</h2><br>
<pre><span id="VALequal"><span class="keyword">val</span> equal</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> <a href="Time_sig.S.html#TYPEt">t</a> -> bool</code></pre><div class="info">
Equality function between two times.<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 id="VALcompare"><span class="keyword">val</span> compare</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> <a href="Time_sig.S.html#TYPEt">t</a> -> int</code></pre><div class="info">
Comparison function between two times.<br>
<b>See also</b> <a href="Utils.Comparable.html#VALcompare">Utils.Comparable.compare.</a><br>
</div>
<pre><span id="VALhash"><span class="keyword">val</span> hash</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> int</code></pre><div class="info">
Hash function for times.<br>
<b>Since</b> 2.0<br>
<b>See also</b> <a href="Utils.Comparable.html#VALhash">Utils.Comparable.hash.</a><br>
</div>
<br>
<h2 id="2_Booleanoperationsontimes">Boolean operations on times</h2><br>
<pre><span id="VALis_pm"><span class="keyword">val</span> is_pm</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> bool</code></pre><div class="info">
Return <code class="code"><span class="keyword">true</span></code> is the time is before midday in the current time zone;
	<code class="code"><span class="keyword">false</span></code> otherwise.<br>
<b>Example:</b> both <code class="code">is_pm (make 10 0 0)</code> and <code class="code">is_pm (make 34 0 0)</code> return
	<code class="code"><span class="keyword">true</span></code>.<br>
</div>
<pre><span id="VALis_am"><span class="keyword">val</span> is_am</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> bool</code></pre><div class="info">
Return <code class="code"><span class="keyword">true</span></code> is the time is after midday in the current time zone;
	<code class="code"><span class="keyword">false</span></code> otherwise.<br>
<b>Example:</b> both <code class="code">is_am (make 20 0 0)</code> and <code class="code">is_am (make 44 0 0)</code> return
	<code class="code"><span class="keyword">true</span></code>.<br>
</div>
<br>
<h2 id="2_Coercions">Coercions</h2><br>
<pre><span id="VALfrom_seconds"><span class="keyword">val</span> from_seconds</span> : <code class="type"><a href="Time_sig.S.html#TYPEsecond">second</a> -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Inverse of <code class="code">to_seconds</code>.<br>
</div>
<pre><span id="VALfrom_minutes"><span class="keyword">val</span> from_minutes</span> : <code class="type">float -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Inverse of <code class="code">to_minutes</code>.<br>
</div>
<pre><span id="VALfrom_hours"><span class="keyword">val</span> from_hours</span> : <code class="type">float -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
Inverse of <code class="code">to_hours</code>.<br>
</div>
<br>
<h2 id="2_Period">Period</h2><br>
<pre><span class="keyword">module</span> <a href="Time_sig.S.Period.html">Period</a>: <code class="code"><span class="keyword">sig</span></code> <a href="Time_sig.S.Period.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
A period is the number of seconds between two times.
</div>
<br>
<h2 id="2_Arithmeticoperationsontimesandperiods">Arithmetic operations on times and periods</h2><br>
<pre><span id="VALadd"><span class="keyword">val</span> add</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -><br>       [< <a href="Period.html#TYPEdate_field">Period.date_field</a> ] Period.period -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">app t p</code> returns <code class="code">t + p</code>.<br>
<b>Example:</b> <code class="code">add (make 20 0 0) (<span class="constructor">Period</span>.minute 70)</code> returns the time
	21:10:0.<br>
</div>
<pre><span id="VALsub"><span class="keyword">val</span> sub</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -><br>       <a href="Time_sig.S.html#TYPEt">t</a> -> [< <a href="Period.html#TYPEdate_field">Period.date_field</a> ] Period.period</code></pre><div class="info">
<code class="code">sub t1 t2</code> returns the period between <code class="code">t1</code> and <code class="code">t2</code>.<br>
</div>
<pre><span id="VALrem"><span class="keyword">val</span> rem</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -><br>       [< <a href="Period.html#TYPEdate_field">Period.date_field</a> ] Period.period -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">rem t p</code> is equivalent to <code class="code">add t (<span class="constructor">Period</span>.opp p)</code>.<br>
</div>
<pre><span id="VALnext"><span class="keyword">val</span> next</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> <a href="Time_sig.S.html#TYPEfield">field</a> -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">next t f</code> returns the time corresponding to the next specified field.<br>
<b>Example:</b> <code class="code">next (make 20 3 31) <span class="keywordsign">`</span><span class="constructor">Minute</span></code> returns the time 20:04:31.
	(i.e. one minute later).<br>
</div>
<pre><span id="VALprev"><span class="keyword">val</span> prev</span> : <code class="type"><a href="Time_sig.S.html#TYPEt">t</a> -> <a href="Time_sig.S.html#TYPEfield">field</a> -> <a href="Time_sig.S.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">prev t f</code> returns the time corresponding to the previous specified
	field.<br>
<b>Example:</b> <code class="code">prev (make 20 3 31) <span class="keywordsign">`</span><span class="constructor">Second</span></code> returns the time 20:03:30
	(i.e. one second ago).<br>
</div>
</body></html>