QOF: qoftime.h Source File

QOF 0.7.5

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

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
96 #ifndef QOF_DISABLE_DEPRECATED
97 typedef struct timespec64
98 {
99 guint64 tv_sec;
100 glong tv_nsec;
101 }Timespec;
102 #endif
103
105 #define QOF_NSECS 1000000000
106
120 typedef struct QofTime64 QofTime;
121
129 typedef gint64 QofTimeSecs;
130
140 void
141 qof_time_add_secs (QofTime * qt, QofTimeSecs secs);
142
152 QofTime *
153 qof_time_add_secs_copy (QofTime * qt, QofTimeSecs secs);
154
160 QofTime *
161 qof_time_new (void);
162
170 QofTime *
171 qof_time_copy (const QofTime *qt);
172
174 void
175 qof_time_free (QofTime * qt);
176
184 void
185 qof_time_set_secs (QofTime * time, QofTimeSecs secs);
186
193 void
194 qof_time_set_nanosecs (QofTime * time, glong nano);
195
202 QofTimeSecs
203 qof_time_get_secs (const QofTime * time);
204
211 glong
212 qof_time_get_nanosecs (const QofTime * time);
218 gboolean
219 qof_time_equal (const QofTime * ta, const QofTime * tb);
220
222 gint
223 qof_time_cmp (const QofTime * ta, const QofTime * tb);
224
234 QofTime *
235 qof_time_diff (const QofTime * ta, const QofTime * tb);
236
242 QofTime *
243 qof_time_abs (QofTime * t);
244
245 gboolean
246 qof_time_is_valid (const QofTime * qt);
247
257 QofTime *
258 qof_time_from_time_t (time_t t, glong nanosecs);
259
269 QofTime *
270 qof_time_set (QofTimeSecs t, glong nanosecs);
271
285 gboolean
286 qof_time_to_time_t (QofTime * ts, time_t * t, glong * nanosecs);
287
300 QofTime *
301 qof_time_from_tm (struct tm *tm, glong nanosecs);
302
310 gboolean
311 qof_time_to_gtimeval (QofTime * qt, GTimeVal * gtv);
312
319 void
320 qof_time_from_gtimeval (QofTime * qt, GTimeVal * gtv);
321
332 QofTime *
333 qof_time_dmy_to_time (guint8 day, guint8 month, guint16 year);
334
348 gboolean
349 qof_time_to_dmy (QofTime * t, guint8 * day, guint8 * month, guint16 * year);
360 GDate *
361 qof_time_to_gdate (QofTime * time);
362
371 QofTime *
372 qof_time_from_gdate (GDate * date);
373
385 GTimeVal *
386 qof_time_get_current_start (void);
387
398 QofTime *
399 qof_time_get_current (void);
400
409 gboolean
410 qof_time_set_day_middle (QofTime * t);
411
420 gboolean
421 qof_time_set_day_start (QofTime * time);
422
431 gboolean
432 qof_time_set_day_end (QofTime * time);
433
442 guint8
443 qof_time_last_mday (QofTime * ts);
444
451 QofTime *
452 qof_time_get_today_start (void);
453
455 QofTime *
456 qof_time_get_today_end (void);
457
463 gchar *
464 qof_time_stamp_now (void);
465
469 #endif /* _QOFTIME_H */
qof_time_from_gdate
QofTime * qof_time_from_gdate(GDate *date)
Convert a GDate to a QofTime.
Definition: qoftime.c:312
qof_time_stamp_now
gchar * qof_time_stamp_now(void)
Definition: qoftime.c:469
Timespec
struct timespec64 Timespec
qof_time_set_day_end
gboolean qof_time_set_day_end(QofTime *time)
set the given QofTime to the last second of that day.
Definition: qoftime.c:327
qof_time_add_secs_copy
QofTime * qof_time_add_secs_copy(QofTime *qt, QofTimeSecs secs)
Create a new QofTime, secs different to an original.
Definition: qoftime.c:73
qof_time_abs
QofTime * qof_time_abs(QofTime *t)
Definition: qoftime.c:196
qof_time_get_secs
QofTimeSecs qof_time_get_secs(const QofTime *time)
Get the number of seconds.
Definition: qoftime.c:133
qof_time_get_today_end
QofTime * qof_time_get_today_end(void)
Definition: qoftime.c:413
qof_time_to_dmy
gboolean qof_time_to_dmy(QofTime *t, guint8 *day, guint8 *month, guint16 *year)
Definition: qoftime.c:439
qof_time_copy
QofTime * qof_time_copy(const QofTime *qt)
Create a copy of a QofTime.
Definition: qoftime.c:223
timespec64
Definition: qoftime.h:97
qof_time_set_secs
void qof_time_set_secs(QofTime *time, QofTimeSecs secs)
Set the number of seconds.
Definition: qoftime.c:117
qof_time_new
QofTime * qof_time_new(void)
create an empty QofTime
Definition: qoftime.c:46
qof_time_from_time_t
QofTime * qof_time_from_time_t(time_t t, glong nanosecs)
Definition: qoftime.c:231
qof_time_to_gdate
GDate * qof_time_to_gdate(QofTime *time)
Convert QofTime to GDate.
Definition: qoftime.c:299
qof_time_set_day_start
gboolean qof_time_set_day_start(QofTime *time)
set the given QofTime to the first second of that day.
Definition: qoftime.c:374
qof_time_dmy_to_time
QofTime * qof_time_dmy_to_time(guint8 day, guint8 month, guint16 year)
Definition: qoftime.c:457
qof_time_get_nanosecs
glong qof_time_get_nanosecs(const QofTime *time)
Get the number of seconds.
Definition: qoftime.c:141
qof_time_get_current
QofTime * qof_time_get_current(void)
Get the current QofTime.
Definition: qoftime.c:362
qof_time_set_day_middle
gboolean qof_time_set_day_middle(QofTime *t)
set the given QofTime to midday on the same day.
Definition: qoftime.c:336
qof_time_free
void qof_time_free(QofTime *qt)
Free a QofTime when no longer required.
Definition: qoftime.c:56
qof_time_cmp
gint qof_time_cmp(const QofTime *ta, const QofTime *tb)
Definition: qoftime.c:165
qof_time_add_secs
void qof_time_add_secs(QofTime *qt, QofTimeSecs secs)
Add (or subtract) seconds from a QofTime.
Definition: qoftime.c:65
qof_time_get_today_start
QofTime * qof_time_get_today_start(void)
Definition: qoftime.c:402
qof_time_get_current_start
GTimeVal * qof_time_get_current_start(void)
Definition: qoftime.c:345
qof_time_equal
gboolean qof_time_equal(const QofTime *ta, const QofTime *tb)
Definition: qoftime.c:148
qof_time_to_time_t
gboolean qof_time_to_time_t(QofTime *ts, time_t *t, glong *nanosecs)
Definition: qoftime.c:237
qof_time_set_nanosecs
void qof_time_set_nanosecs(QofTime *time, glong nano)
Set the number of seconds.
Definition: qoftime.c:125
qof_time_last_mday
guint8 qof_time_last_mday(QofTime *ts)
Definition: qoftime.c:423
qof_time_set
QofTime * qof_time_set(QofTimeSecs t, glong nanosecs)
Definition: qoftime.c:210
QofTimeSecs
gint64 QofTimeSecs
Replacement for time_t.
Definition: qoftime.h:129
QofTime
struct QofTime64 QofTime
Use a 64-bit signed int QofTime.
Definition: qoftime.h:120
qof_time_from_tm
QofTime * qof_time_from_tm(struct tm *tm, glong nanosecs)
Convert a broken-down into a QofTime.
Definition: qoftime.c:258
qof_time_from_gtimeval
void qof_time_from_gtimeval(QofTime *qt, GTimeVal *gtv)
Convert a QofTime to a GTimeVal.
Definition: qoftime.c:290
qof_time_to_gtimeval
gboolean qof_time_to_gtimeval(QofTime *qt, GTimeVal *gtv)
Convert a QofTime to a GTimeVal.
Definition: qoftime.c:272
qof_time_diff
QofTime * qof_time_diff(const QofTime *ta, const QofTime *tb)
difference between two QofTimes.
Definition: qoftime.c:182