4
4
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5
5
<title>Time-Related Utility Functions</title>
6
<meta name="generator" content="DocBook XSL Stylesheets V1.71.1">
6
<meta name="generator" content="DocBook XSL Stylesheets V1.73.1">
7
7
<link rel="start" href="index.html" title="Evolution API Reference: libedataserver, utility library">
8
8
<link rel="up" href="ch01.html" title="Evolution API Reference: libedataserver, utility library">
9
9
<link rel="prev" href="ESourceList.html" title="ESourceList">
10
10
<link rel="next" href="libedataserver-e-trie.html" title="ETrie">
11
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
11
<meta name="generator" content="GTK-Doc V1.10 (XML mode)">
12
12
<link rel="stylesheet" href="style.css" type="text/css">
13
13
<link rel="chapter" href="ch01.html" title="Evolution API Reference: libedataserver, utility library">
14
14
<link rel="index" href="ix01.html" title="Index">
22
22
<th width="100%" align="center">Evolution API Reference: libedataserver, utility library</th>
23
23
<td><a accesskey="n" href="libedataserver-e-trie.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
25
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2600586" class="shortcut">Top</a>
25
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2601585" class="shortcut">Top</a>
27
<a href="#id2622300" class="shortcut">Description</a></nobr></td></tr>
27
<a href="#id2648799" class="shortcut">Description</a></nobr></td></tr>
29
29
<div class="refentry" lang="en">
30
30
<a name="libedataserver-e-time-utils"></a><div class="titlepage"></div>
31
31
<div class="refnamediv"><table width="100%"><tr>
34
<a name="id2600586"></a><span class="refentrytitle">Time-Related Utility Functions</span>
34
<a name="id2601585"></a><span class="refentrytitle">Time-Related Utility Functions</span>
36
36
<p>Time-Related Utility Functions — Utility functions for time structure manipulation.</p>
46
enum <a href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a>;
47
<a href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a> <a href="libedataserver-e-time-utils.html#e-time-parse-date-and-time">e_time_parse_date_and_time</a> (const char *value,
49
<a href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a> <a href="libedataserver-e-time-utils.html#e-time-parse-date">e_time_parse_date</a> (const char *value,
51
<a href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a> <a href="libedataserver-e-time-utils.html#e-time-parse-time">e_time_parse_time</a> (const char *value,
53
void <a href="libedataserver-e-time-utils.html#e-time-format-date-and-time">e_time_format_date_and_time</a> (struct tm *date_tm,
55
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
56
>gboolean</a> use_24_hour_format,
58
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
59
>gboolean</a> show_midnight,
61
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
62
>gboolean</a> show_zero_seconds,
65
void <a href="libedataserver-e-time-utils.html#e-time-format-time">e_time_format_time</a> (struct tm *date_tm,
67
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
68
>gboolean</a> use_24_hour_format,
70
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
71
>gboolean</a> show_zero_seconds,
74
time_t <a href="libedataserver-e-time-utils.html#e-mktime-utc">e_mktime_utc</a> (struct tm *tm);
75
void <a href="libedataserver-e-time-utils.html#e-localtime-with-offset">e_localtime_with_offset</a> (time_t tt,
46
enum <a class="link" href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a>;
47
<a class="link" href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a> <a class="link" href="libedataserver-e-time-utils.html#e-time-parse-date-and-time">e_time_parse_date_and_time</a> (const char *value,
49
<a class="link" href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a> <a class="link" href="libedataserver-e-time-utils.html#e-time-parse-date">e_time_parse_date</a> (const char *value,
51
<a class="link" href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a> <a class="link" href="libedataserver-e-time-utils.html#e-time-parse-time">e_time_parse_time</a> (const char *value,
53
void <a class="link" href="libedataserver-e-time-utils.html#e-time-format-date-and-time">e_time_format_date_and_time</a> (struct tm *date_tm,
54
gboolean use_24_hour_format,
55
gboolean show_midnight,
56
gboolean show_zero_seconds,
59
void <a class="link" href="libedataserver-e-time-utils.html#e-time-format-time">e_time_format_time</a> (struct tm *date_tm,
60
gboolean use_24_hour_format,
61
gboolean show_zero_seconds,
64
time_t <a class="link" href="libedataserver-e-time-utils.html#e-mktime-utc">e_mktime_utc</a> (struct tm *tm);
65
void <a class="link" href="libedataserver-e-time-utils.html#e-localtime-with-offset">e_localtime_with_offset</a> (time_t tt,
80
70
<div class="refsect1" lang="en">
81
<a name="id2622300"></a><h2>Description</h2>
71
<a name="id2648799"></a><h2>Description</h2>
86
76
<div class="refsect1" lang="en">
87
<a name="id2622315"></a><h2>Details</h2>
77
<a name="id2648815"></a><h2>Details</h2>
88
78
<div class="refsect2" lang="en">
89
<a name="id2622326"></a><h3>
79
<a name="id2648826"></a><h3>
90
80
<a name="ETimeParseStatus"></a>enum ETimeParseStatus</h3>
91
<a class="indexterm" name="id2622339"></a><pre class="programlisting">typedef enum {
81
<a class="indexterm" name="id2648838"></a><pre class="programlisting">typedef enum {
94
84
E_TIME_PARSE_INVALID
103
93
<col align="left" valign="top">
106
<td><span class="term"><a name="E-TIME-PARSE-OK:CAPS"></a><code class="literal">E_TIME_PARSE_OK</code></span></td>
96
<td><p><span class="term"><a name="E-TIME-PARSE-OK:CAPS"></a><code class="literal">E_TIME_PARSE_OK</code></span></p></td>
107
97
<td> The time string was parsed successfully.
111
<td><span class="term"><a name="E-TIME-PARSE-NONE:CAPS"></a><code class="literal">E_TIME_PARSE_NONE</code></span></td>
101
<td><p><span class="term"><a name="E-TIME-PARSE-NONE:CAPS"></a><code class="literal">E_TIME_PARSE_NONE</code></span></p></td>
112
102
<td> The time string was empty.
116
<td><span class="term"><a name="E-TIME-PARSE-INVALID:CAPS"></a><code class="literal">E_TIME_PARSE_INVALID</code></span></td>
106
<td><p><span class="term"><a name="E-TIME-PARSE-INVALID:CAPS"></a><code class="literal">E_TIME_PARSE_INVALID</code></span></p></td>
117
107
<td> The time string was not formatted correctly.
124
114
<div class="refsect2" lang="en">
125
<a name="id2622427"></a><h3>
115
<a name="id2645340"></a><h3>
126
116
<a name="e-time-parse-date-and-time"></a>e_time_parse_date_and_time ()</h3>
127
<a class="indexterm" name="id2622438"></a><pre class="programlisting"><a href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a> e_time_parse_date_and_time (const char *value,
117
<a class="indexterm" name="id2645352"></a><pre class="programlisting"><a class="link" href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a> e_time_parse_date_and_time (const char *value,
128
118
struct tm *result);</pre>
130
120
Parses a string <em class="parameter"><code>value</code></em> containing a date and a time and stores the
131
121
result in <em class="parameter"><code>result</code></em>. The date in <em class="parameter"><code>value</code></em> is expected to be in a format
132
like "Wed 3/13/00 14:20:00", though <a
133
href="/opt/gnome/share/gtk-doc/html/libbonobo/libbonobo-bonobo-i18n.html#gettext"
134
><code class="function">gettext()</code></a> is used to support the
122
like "Wed 3/13/00 14:20:00", though <code class="function">gettext()</code> is used to support the
135
123
appropriate local formats. There is also some leniency on the
136
124
format of the string, e.g. the weekday can be skipped or 12-hour
137
125
formats with am/pm can be used.</p>
142
130
<col align="left" valign="top">
145
<td><span class="term"><em class="parameter"><code>value</code></em> :</span></td>
133
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
146
134
<td> The string to parse a date and time from.
150
<td><span class="term"><em class="parameter"><code>result</code></em> :</span></td>
151
<td> A <a href="libedataserver-e-util.html#tm"><span class="type">tm</span></a> to store the result in.
138
<td><p><span class="term"><em class="parameter"><code>result</code></em> :</span></p></td>
139
<td> A <a class="link" href="libedataserver-e-util.html#tm"><span class="type">tm</span></a> to store the result in.
155
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
143
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
156
144
<td> E_TIME_PARSE_OK if the string was successfully parsed,
157
145
E_TIME_PARSE_NONE if the string was empty, or
158
146
E_TIME_PARSE_INVALID if the string could not be parsed.
165
153
<div class="refsect2" lang="en">
166
<a name="id2618849"></a><h3>
154
<a name="id2645475"></a><h3>
167
155
<a name="e-time-parse-date"></a>e_time_parse_date ()</h3>
168
<a class="indexterm" name="id2618862"></a><pre class="programlisting"><a href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a> e_time_parse_date (const char *value,
156
<a class="indexterm" name="id2645487"></a><pre class="programlisting"><a class="link" href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a> e_time_parse_date (const char *value,
169
157
struct tm *result);</pre>
171
159
Takes in a date string entered by the user and tries to convert it to
172
a struct <a href="libedataserver-e-util.html#tm"><span class="type">tm</span></a>.</p>
160
a struct <a class="link" href="libedataserver-e-util.html#tm"><span class="type">tm</span></a>.</p>
177
165
<col align="left" valign="top">
180
<td><span class="term"><em class="parameter"><code>value</code></em> :</span></td>
168
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
181
169
<td> A date string.
185
<td><span class="term"><em class="parameter"><code>result</code></em> :</span></td>
173
<td><p><span class="term"><em class="parameter"><code>result</code></em> :</span></p></td>
186
174
<td> Return value for the parsed date.
190
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
191
<td> An <a href="libedataserver-e-time-utils.html#ETimeParseStatus"><span class="type">ETimeParseStatus</span></a> result code indicating whether
178
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
179
<td> An <a class="link" href="libedataserver-e-time-utils.html#ETimeParseStatus"><span class="type">ETimeParseStatus</span></a> result code indicating whether
192
180
<em class="parameter"><code>value</code></em> was an empty string, a valid date, or an invalid date.
199
187
<div class="refsect2" lang="en">
200
<a name="id2618965"></a><h3>
188
<a name="id2634041"></a><h3>
201
189
<a name="e-time-parse-time"></a>e_time_parse_time ()</h3>
202
<a class="indexterm" name="id2618977"></a><pre class="programlisting"><a href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a> e_time_parse_time (const char *value,
190
<a class="indexterm" name="id2634054"></a><pre class="programlisting"><a class="link" href="libedataserver-e-time-utils.html#ETimeParseStatus">ETimeParseStatus</a> e_time_parse_time (const char *value,
203
191
struct tm *result);</pre>
205
193
Parses <em class="parameter"><code>value</code></em>, a string containing a time. <em class="parameter"><code>value</code></em> is expected to be
206
in a format like "14:20:00". <a
207
href="/opt/gnome/share/gtk-doc/html/libbonobo/libbonobo-bonobo-i18n.html#gettext"
208
><code class="function">gettext()</code></a> is used to
194
in a format like "14:20:00". <code class="function">gettext()</code> is used to
209
195
support the appropriate local formats and slightly
210
196
different formats, such as 12-hour formats with am/pm,
211
197
are accepted as well.</p>
216
202
<col align="left" valign="top">
219
<td><span class="term"><em class="parameter"><code>value</code></em> :</span></td>
205
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
220
206
<td> The string to parse a time from.
224
<td><span class="term"><em class="parameter"><code>result</code></em> :</span></td>
225
<td> A <a href="libedataserver-e-util.html#tm"><span class="type">tm</span></a> to store the result in.
210
<td><p><span class="term"><em class="parameter"><code>result</code></em> :</span></p></td>
211
<td> A <a class="link" href="libedataserver-e-util.html#tm"><span class="type">tm</span></a> to store the result in.
229
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
230
<td> An <a href="libedataserver-e-time-utils.html#ETimeParseStatus"><span class="type">ETimeParseStatus</span></a> result code indicating whether
215
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
216
<td> An <a class="link" href="libedataserver-e-time-utils.html#ETimeParseStatus"><span class="type">ETimeParseStatus</span></a> result code indicating whether
231
217
<em class="parameter"><code>value</code></em> was an empty string, a valid date, or an invalid date.
238
224
<div class="refsect2" lang="en">
239
<a name="id2619103"></a><h3>
225
<a name="id2634179"></a><h3>
240
226
<a name="e-time-format-date-and-time"></a>e_time_format_date_and_time ()</h3>
241
<a class="indexterm" name="id2619114"></a><pre class="programlisting">void e_time_format_date_and_time (struct tm *date_tm,
243
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
244
>gboolean</a> use_24_hour_format,
246
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
247
>gboolean</a> show_midnight,
249
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
250
>gboolean</a> show_zero_seconds,
227
<a class="indexterm" name="id2634191"></a><pre class="programlisting">void e_time_format_date_and_time (struct tm *date_tm,
228
gboolean use_24_hour_format,
229
gboolean show_midnight,
230
gboolean show_zero_seconds,
252
232
int buffer_size);</pre>
254
234
Creates a string representation of the time value <em class="parameter"><code>date_tm</code></em> and
255
235
stores it in <em class="parameter"><code>buffer</code></em>. <em class="parameter"><code>buffer_size</code></em> should be at least 64 to be
256
safe. If <em class="parameter"><code>show_midnight</code></em> is <a
257
href="/opt/gnome/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"
258
><span class="type">FALSE</span></a>, and the time is midnight, then
236
safe. If <em class="parameter"><code>show_midnight</code></em> is <span class="type">FALSE</span>, and the time is midnight, then
259
237
only the date is stored in <em class="parameter"><code>buffer</code></em>. If <em class="parameter"><code>show_zero_seconds</code></em> is
261
href="/opt/gnome/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"
262
><span class="type">FALSE</span></a>, then if the time has zero seconds only the hour and minute
238
<span class="type">FALSE</span>, then if the time has zero seconds only the hour and minute
263
239
of the time are stored in <em class="parameter"><code>buffer</code></em>.</p>
268
244
<col align="left" valign="top">
271
<td><span class="term"><em class="parameter"><code>date_tm</code></em> :</span></td>
272
<td> The <a href="libedataserver-e-util.html#tm"><span class="type">tm</span></a> to convert to a string.
276
<td><span class="term"><em class="parameter"><code>use_24_hour_format</code></em> :</span></td>
278
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
279
><span class="type">gboolean</span></a>.
283
<td><span class="term"><em class="parameter"><code>show_midnight</code></em> :</span></td>
285
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
286
><span class="type">gboolean</span></a>.
290
<td><span class="term"><em class="parameter"><code>show_zero_seconds</code></em> :</span></td>
292
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
293
><span class="type">gboolean</span></a>.
297
<td><span class="term"><em class="parameter"><code>buffer</code></em> :</span></td>
247
<td><p><span class="term"><em class="parameter"><code>date_tm</code></em> :</span></p></td>
248
<td> The <a class="link" href="libedataserver-e-util.html#tm"><span class="type">tm</span></a> to convert to a string.
252
<td><p><span class="term"><em class="parameter"><code>use_24_hour_format</code></em> :</span></p></td>
253
<td> A <span class="type">gboolean</span>.
257
<td><p><span class="term"><em class="parameter"><code>show_midnight</code></em> :</span></p></td>
258
<td> A <span class="type">gboolean</span>.
262
<td><p><span class="term"><em class="parameter"><code>show_zero_seconds</code></em> :</span></p></td>
263
<td> A <span class="type">gboolean</span>.
267
<td><p><span class="term"><em class="parameter"><code>buffer</code></em> :</span></p></td>
298
268
<td> A <span class="type">char</span> buffer to store the time string in.
302
<td><span class="term"><em class="parameter"><code>buffer_size</code></em> :</span></td>
272
<td><p><span class="term"><em class="parameter"><code>buffer_size</code></em> :</span></p></td>
303
273
<td> The length of <em class="parameter"><code>buffer</code></em>.
310
280
<div class="refsect2" lang="en">
311
<a name="id2621562"></a><h3>
281
<a name="id2647896"></a><h3>
312
282
<a name="e-time-format-time"></a>e_time_format_time ()</h3>
313
<a class="indexterm" name="id2621575"></a><pre class="programlisting">void e_time_format_time (struct tm *date_tm,
315
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
316
>gboolean</a> use_24_hour_format,
318
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
319
>gboolean</a> show_zero_seconds,
283
<a class="indexterm" name="id2647909"></a><pre class="programlisting">void e_time_format_time (struct tm *date_tm,
284
gboolean use_24_hour_format,
285
gboolean show_zero_seconds,
321
287
int buffer_size);</pre>
329
295
<col align="left" valign="top">
332
<td><span class="term"><em class="parameter"><code>date_tm</code></em> :</span></td>
333
<td> The <a href="libedataserver-e-util.html#tm"><span class="type">tm</span></a> to convert to a string.
337
<td><span class="term"><em class="parameter"><code>use_24_hour_format</code></em> :</span></td>
339
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
340
><span class="type">gboolean</span></a>.
344
<td><span class="term"><em class="parameter"><code>show_zero_seconds</code></em> :</span></td>
346
href="/opt/gnome/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"
347
><span class="type">gboolean</span></a>.
351
<td><span class="term"><em class="parameter"><code>buffer</code></em> :</span></td>
298
<td><p><span class="term"><em class="parameter"><code>date_tm</code></em> :</span></p></td>
299
<td> The <a class="link" href="libedataserver-e-util.html#tm"><span class="type">tm</span></a> to convert to a string.
303
<td><p><span class="term"><em class="parameter"><code>use_24_hour_format</code></em> :</span></p></td>
304
<td> A <span class="type">gboolean</span>.
308
<td><p><span class="term"><em class="parameter"><code>show_zero_seconds</code></em> :</span></p></td>
309
<td> A <span class="type">gboolean</span>.
313
<td><p><span class="term"><em class="parameter"><code>buffer</code></em> :</span></p></td>
352
314
<td> The <span class="type">char</span> buffer to store the result in.
356
<td><span class="term"><em class="parameter"><code>buffer_size</code></em> :</span></td>
318
<td><p><span class="term"><em class="parameter"><code>buffer_size</code></em> :</span></p></td>
357
319
<td> The length of <em class="parameter"><code>buffer</code></em>.
374
336
<col align="left" valign="top">
377
<td><span class="term"><em class="parameter"><code>tm</code></em> :</span></td>
378
<td> The <a href="libedataserver-e-util.html#tm"><span class="type">tm</span></a> to convert to a calendar time representation.
339
<td><p><span class="term"><em class="parameter"><code>tm</code></em> :</span></p></td>
340
<td> The <a class="link" href="libedataserver-e-util.html#tm"><span class="type">tm</span></a> to convert to a calendar time representation.
382
<td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
344
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
383
345
<td> The calendar time representation of <em class="parameter"><code>tm</code></em>.
404
366
<col align="left" valign="top">
407
<td><span class="term"><em class="parameter"><code>tt</code></em> :</span></td>
369
<td><p><span class="term"><em class="parameter"><code>tt</code></em> :</span></p></td>
408
370
<td> The <span class="type">time_t</span> to convert.
412
<td><span class="term"><em class="parameter"><code>tm</code></em> :</span></td>
413
<td> The <a href="libedataserver-e-util.html#tm"><span class="type">tm</span></a> to store the result in.
374
<td><p><span class="term"><em class="parameter"><code>tm</code></em> :</span></p></td>
375
<td> The <a class="link" href="libedataserver-e-util.html#tm"><span class="type">tm</span></a> to store the result in.
417
<td><span class="term"><em class="parameter"><code>offset</code></em> :</span></td>
379
<td><p><span class="term"><em class="parameter"><code>offset</code></em> :</span></p></td>
418
380
<td> The <span class="type">int</span> to store the offset in.