QOF  0.8.7
qoftime.h
Go to the documentation of this file.
1 /***************************************************************************
2  * qoftime.h - QofTime, 64bit UTC time handling (seconds).
3  * Rewritten from scratch for QOF 0.7.0
4  *
5  * Fri May 5 15:05:32 2006
6  * Copyright 2006 Neil Williams
7  * linux@codehelp.co.uk
8  ****************************************************************************/
9 /*
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef _QOFTIME_H
26 #define _QOFTIME_H
27 
90 #include "config.h"
91 #include <time.h>
92 
94 #define QOF_MOD_TIME "qof-time"
95 
97 #define QOF_NSECS 1000000000
98 
112 typedef struct QofTime64 QofTime;
113 
121 typedef gint64 QofTimeSecs;
122 
132 void
134 
144 QofTime *
146 
152 QofTime *
153 qof_time_new (void);
154 
162 QofTime *
163 qof_time_copy (const QofTime *qt);
164 
166 void
167 qof_time_free (QofTime * qt);
168 
176 void
177 qof_time_set_secs (QofTime * time, QofTimeSecs secs);
178 
185 void
186 qof_time_set_nanosecs (QofTime * time, glong nano);
187 
195 qof_time_get_secs (const QofTime * time);
196 
203 glong
204 qof_time_get_nanosecs (const QofTime * time);
210 gboolean
211 qof_time_equal (const QofTime * ta, const QofTime * tb);
212 
214 gint
215 qof_time_cmp (const QofTime * ta, const QofTime * tb);
216 
226 QofTime *
227 qof_time_diff (const QofTime * ta, const QofTime * tb);
228 
234 QofTime *
235 qof_time_abs (QofTime * t);
236 
237 gboolean
238 qof_time_is_valid (const QofTime * qt);
239 
249 QofTime *
250 qof_time_from_time_t (time_t t, glong nanosecs);
251 
261 QofTime *
262 qof_time_set (QofTimeSecs t, glong nanosecs);
263 
277 gboolean
278 qof_time_to_time_t (QofTime * ts, time_t * t, glong * nanosecs);
279 
292 QofTime *
293 qof_time_from_tm (struct tm *tm, glong nanosecs);
294 
302 gboolean
303 qof_time_to_gtimeval (QofTime * qt, GTimeVal * gtv);
304 
311 void
312 qof_time_from_gtimeval (QofTime * qt, GTimeVal * gtv);
313 
324 QofTime *
325 qof_time_dmy_to_time (guint8 day, guint8 month, guint16 year);
326 
340 gboolean
341 qof_time_to_dmy (QofTime * t, guint8 * day, guint8 * month, guint16 * year);
352 GDate *
353 qof_time_to_gdate (QofTime * time);
354 
363 QofTime *
364 qof_time_from_gdate (GDate * date);
365 
377 GTimeVal *
379 
390 QofTime *
391 qof_time_get_current (void);
392 
401 gboolean
403 
412 gboolean
414 
423 gboolean
425 
434 guint8
436 
443 QofTime *
445 
447 QofTime *
449 
455 gchar *
456 qof_time_stamp_now (void);
457 
461 #endif /* _QOFTIME_H */
QofTime * qof_time_from_gdate(GDate *date)
Convert a GDate to a QofTime.
Definition: qoftime.c:312
gchar * qof_time_stamp_now(void)
Definition: qoftime.c:469
gboolean qof_time_set_day_end(QofTime *time)
set the given QofTime to the last second of that day.
Definition: qoftime.c:327
QofTime * qof_time_add_secs_copy(QofTime *qt, QofTimeSecs secs)
Create a new QofTime, secs different to an original.
Definition: qoftime.c:73
QofTime * qof_time_abs(QofTime *t)
Definition: qoftime.c:196
QofTimeSecs qof_time_get_secs(const QofTime *time)
Get the number of seconds.
Definition: qoftime.c:133
QofTime * qof_time_get_today_end(void)
Definition: qoftime.c:413
gboolean qof_time_to_dmy(QofTime *t, guint8 *day, guint8 *month, guint16 *year)
Definition: qoftime.c:439
QofTime * qof_time_copy(const QofTime *qt)
Create a copy of a QofTime.
Definition: qoftime.c:223
void qof_time_set_secs(QofTime *time, QofTimeSecs secs)
Set the number of seconds.
Definition: qoftime.c:117
QofTime * qof_time_new(void)
create an empty QofTime
Definition: qoftime.c:46
QofTime * qof_time_from_time_t(time_t t, glong nanosecs)
Definition: qoftime.c:231
GDate * qof_time_to_gdate(QofTime *time)
Convert QofTime to GDate.
Definition: qoftime.c:299
gboolean qof_time_set_day_start(QofTime *time)
set the given QofTime to the first second of that day.
Definition: qoftime.c:374
QofTime * qof_time_dmy_to_time(guint8 day, guint8 month, guint16 year)
Definition: qoftime.c:457
glong qof_time_get_nanosecs(const QofTime *time)
Get the number of seconds.
Definition: qoftime.c:141
QofTime * qof_time_get_current(void)
Get the current QofTime.
Definition: qoftime.c:362
gboolean qof_time_set_day_middle(QofTime *t)
set the given QofTime to midday on the same day.
Definition: qoftime.c:336
void qof_time_free(QofTime *qt)
Free a QofTime when no longer required.
Definition: qoftime.c:56
gint qof_time_cmp(const QofTime *ta, const QofTime *tb)
Definition: qoftime.c:165
void qof_time_add_secs(QofTime *qt, QofTimeSecs secs)
Add (or subtract) seconds from a QofTime.
Definition: qoftime.c:65
QofTime * qof_time_get_today_start(void)
Definition: qoftime.c:402
GTimeVal * qof_time_get_current_start(void)
Definition: qoftime.c:345
gboolean qof_time_equal(const QofTime *ta, const QofTime *tb)
Definition: qoftime.c:148
gboolean qof_time_to_time_t(QofTime *ts, time_t *t, glong *nanosecs)
Definition: qoftime.c:237
void qof_time_set_nanosecs(QofTime *time, glong nano)
Set the number of seconds.
Definition: qoftime.c:125
guint8 qof_time_last_mday(QofTime *ts)
Definition: qoftime.c:423
QofTime * qof_time_set(QofTimeSecs t, glong nanosecs)
Definition: qoftime.c:210
gint64 QofTimeSecs
Replacement for time_t.
Definition: qoftime.h:121
struct QofTime64 QofTime
Use a 64-bit signed int QofTime.
Definition: qoftime.h:112
QofTime * qof_time_from_tm(struct tm *tm, glong nanosecs)
Convert a broken-down into a QofTime.
Definition: qoftime.c:258
void qof_time_from_gtimeval(QofTime *qt, GTimeVal *gtv)
Convert a QofTime to a GTimeVal.
Definition: qoftime.c:290
gboolean qof_time_to_gtimeval(QofTime *qt, GTimeVal *gtv)
Convert a QofTime to a GTimeVal.
Definition: qoftime.c:272
QofTime * qof_time_diff(const QofTime *ta, const QofTime *tb)
difference between two QofTimes.
Definition: qoftime.c:182