QOF  0.8.7
qoftime.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  *        qoftime.h - QofTime, 64bit UTC time handling (seconds).
00003  *       Rewritten from scratch for QOF 0.7.0
00004  *
00005  *  Fri May  5 15:05:32 2006
00006  *  Copyright  2006  Neil Williams
00007  *  linux@codehelp.co.uk
00008  ****************************************************************************/
00009 /*
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA  02110-1301,  USA
00023  */
00024 
00025 #ifndef _QOFTIME_H
00026 #define _QOFTIME_H
00027 
00090 #include "config.h"
00091 #include <time.h>
00092 
00094 #define QOF_MOD_TIME "qof-time"
00095 
00097 #define QOF_NSECS 1000000000
00098 
00112 typedef struct QofTime64 QofTime;
00113 
00121 typedef gint64 QofTimeSecs;
00122 
00132 void
00133 qof_time_add_secs (QofTime * qt, QofTimeSecs secs);
00134 
00144 QofTime *
00145 qof_time_add_secs_copy (QofTime * qt, QofTimeSecs secs);
00146 
00152 QofTime *
00153 qof_time_new (void);
00154 
00162 QofTime *
00163 qof_time_copy (const QofTime *qt);
00164 
00166 void 
00167 qof_time_free (QofTime * qt);
00168 
00176 void 
00177 qof_time_set_secs (QofTime * time, QofTimeSecs secs);
00178 
00185 void 
00186 qof_time_set_nanosecs (QofTime * time, glong nano);
00187 
00194 QofTimeSecs 
00195 qof_time_get_secs (const QofTime * time);
00196 
00203 glong 
00204 qof_time_get_nanosecs (const QofTime * time);
00210 gboolean 
00211 qof_time_equal (const QofTime * ta, const QofTime * tb);
00212 
00214 gint 
00215 qof_time_cmp (const QofTime * ta, const QofTime * tb);
00216 
00226 QofTime *
00227 qof_time_diff (const QofTime * ta, const QofTime * tb);
00228 
00234 QofTime *
00235 qof_time_abs (QofTime * t);
00236 
00237 gboolean
00238 qof_time_is_valid (const QofTime * qt);
00239 
00249 QofTime *
00250 qof_time_from_time_t (time_t t, glong nanosecs);
00251 
00261 QofTime *
00262 qof_time_set (QofTimeSecs t, glong nanosecs);
00263 
00277 gboolean 
00278 qof_time_to_time_t (QofTime * ts, time_t * t, glong * nanosecs);
00279 
00292 QofTime *
00293 qof_time_from_tm (struct tm *tm, glong nanosecs);
00294 
00302 gboolean 
00303 qof_time_to_gtimeval (QofTime * qt, GTimeVal * gtv);
00304 
00311 void 
00312 qof_time_from_gtimeval (QofTime * qt, GTimeVal * gtv);
00313 
00324 QofTime *
00325 qof_time_dmy_to_time (guint8 day, guint8 month, guint16 year);
00326 
00340 gboolean
00341 qof_time_to_dmy (QofTime * t, guint8 * day, guint8 * month, guint16 * year);
00352 GDate *
00353 qof_time_to_gdate (QofTime * time);
00354 
00363 QofTime *
00364 qof_time_from_gdate (GDate * date);
00365 
00377 GTimeVal *
00378 qof_time_get_current_start (void);
00379 
00390 QofTime *
00391 qof_time_get_current (void);
00392 
00401 gboolean 
00402 qof_time_set_day_middle (QofTime * t);
00403 
00412 gboolean 
00413 qof_time_set_day_start (QofTime * time);
00414 
00423 gboolean 
00424 qof_time_set_day_end (QofTime * time);
00425 
00434 guint8 
00435 qof_time_last_mday (QofTime * ts);
00436 
00443 QofTime *
00444 qof_time_get_today_start (void);
00445 
00447 QofTime *
00448 qof_time_get_today_end (void);
00449 
00455 gchar *
00456 qof_time_stamp_now (void);
00457 
00461 #endif /* _QOFTIME_H */