1/*
2 * Copyright (C) 2009-2010 Christian Hergert <chris@dronelabs.com>
3 * Copyright © 2010 Codethink Limited
4 *
5 * This library is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; either version 2.1 of the
8 * licence, or (at your option) any later version.
9 *
10 * This is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18 * USA.
19 *
20 * Authors: Christian Hergert <chris@dronelabs.com>
21 * Thiago Santos <thiago.sousa.santos@collabora.co.uk>
22 * Emmanuele Bassi <ebassi@linux.intel.com>
23 * Ryan Lortie <desrt@desrt.ca>
24 */
25
26#ifndef __G_DATE_TIME_H__
27#define __G_DATE_TIME_H__
28
29#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
30#error "Only <glib.h> can be included directly."
31#endif
32
33#include <glib/gtimezone.h>
34
35G_BEGIN_DECLS
36
37/**
38 * G_TIME_SPAN_DAY:
39 *
40 * Evaluates to a time span of one day.
41 *
42 * Since: 2.26
43 */
44#define G_TIME_SPAN_DAY (G_GINT64_CONSTANT (86400000000))
45
46/**
47 * G_TIME_SPAN_HOUR:
48 *
49 * Evaluates to a time span of one hour.
50 *
51 * Since: 2.26
52 */
53#define G_TIME_SPAN_HOUR (G_GINT64_CONSTANT (3600000000))
54
55/**
56 * G_TIME_SPAN_MINUTE:
57 *
58 * Evaluates to a time span of one minute.
59 *
60 * Since: 2.26
61 */
62#define G_TIME_SPAN_MINUTE (G_GINT64_CONSTANT (60000000))
63
64/**
65 * G_TIME_SPAN_SECOND:
66 *
67 * Evaluates to a time span of one second.
68 *
69 * Since: 2.26
70 */
71#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT (1000000))
72
73/**
74 * G_TIME_SPAN_MILLISECOND:
75 *
76 * Evaluates to a time span of one millisecond.
77 *
78 * Since: 2.26
79 */
80#define G_TIME_SPAN_MILLISECOND (G_GINT64_CONSTANT (1000))
81
82/**
83 * GTimeSpan:
84 *
85 * A value representing an interval of time, in microseconds.
86 *
87 * Since: 2.26
88 */
89typedef gint64 GTimeSpan;
90
91/**
92 * GDateTime:
93 *
94 * `GDateTime` is an opaque structure whose members
95 * cannot be accessed directly.
96 *
97 * Since: 2.26
98 */
99typedef struct _GDateTime GDateTime;
100
101GLIB_AVAILABLE_IN_ALL
102void g_date_time_unref (GDateTime *datetime);
103GLIB_AVAILABLE_IN_ALL
104GDateTime * g_date_time_ref (GDateTime *datetime);
105
106GLIB_AVAILABLE_IN_ALL
107GDateTime * g_date_time_new_now (GTimeZone *tz);
108GLIB_AVAILABLE_IN_ALL
109GDateTime * g_date_time_new_now_local (void);
110GLIB_AVAILABLE_IN_ALL
111GDateTime * g_date_time_new_now_utc (void);
112
113GLIB_AVAILABLE_IN_ALL
114GDateTime * g_date_time_new_from_unix_local (gint64 t);
115GLIB_AVAILABLE_IN_ALL
116GDateTime * g_date_time_new_from_unix_utc (gint64 t);
117
118GLIB_AVAILABLE_IN_ALL
119GDateTime * g_date_time_new_from_timeval_local (const GTimeVal *tv);
120GLIB_AVAILABLE_IN_ALL
121GDateTime * g_date_time_new_from_timeval_utc (const GTimeVal *tv);
122
123GLIB_AVAILABLE_IN_ALL
124GDateTime * g_date_time_new (GTimeZone *tz,
125 gint year,
126 gint month,
127 gint day,
128 gint hour,
129 gint minute,
130 gdouble seconds);
131GLIB_AVAILABLE_IN_ALL
132GDateTime * g_date_time_new_local (gint year,
133 gint month,
134 gint day,
135 gint hour,
136 gint minute,
137 gdouble seconds);
138GLIB_AVAILABLE_IN_ALL
139GDateTime * g_date_time_new_utc (gint year,
140 gint month,
141 gint day,
142 gint hour,
143 gint minute,
144 gdouble seconds);
145
146GLIB_AVAILABLE_IN_ALL
147G_GNUC_WARN_UNUSED_RESULT
148GDateTime * g_date_time_add (GDateTime *datetime,
149 GTimeSpan timespan);
150
151GLIB_AVAILABLE_IN_ALL
152G_GNUC_WARN_UNUSED_RESULT
153GDateTime * g_date_time_add_years (GDateTime *datetime,
154 gint years);
155GLIB_AVAILABLE_IN_ALL
156G_GNUC_WARN_UNUSED_RESULT
157GDateTime * g_date_time_add_months (GDateTime *datetime,
158 gint months);
159GLIB_AVAILABLE_IN_ALL
160G_GNUC_WARN_UNUSED_RESULT
161GDateTime * g_date_time_add_weeks (GDateTime *datetime,
162 gint weeks);
163GLIB_AVAILABLE_IN_ALL
164G_GNUC_WARN_UNUSED_RESULT
165GDateTime * g_date_time_add_days (GDateTime *datetime,
166 gint days);
167
168GLIB_AVAILABLE_IN_ALL
169G_GNUC_WARN_UNUSED_RESULT
170GDateTime * g_date_time_add_hours (GDateTime *datetime,
171 gint hours);
172GLIB_AVAILABLE_IN_ALL
173G_GNUC_WARN_UNUSED_RESULT
174GDateTime * g_date_time_add_minutes (GDateTime *datetime,
175 gint minutes);
176GLIB_AVAILABLE_IN_ALL
177G_GNUC_WARN_UNUSED_RESULT
178GDateTime * g_date_time_add_seconds (GDateTime *datetime,
179 gdouble seconds);
180
181GLIB_AVAILABLE_IN_ALL
182G_GNUC_WARN_UNUSED_RESULT
183GDateTime * g_date_time_add_full (GDateTime *datetime,
184 gint years,
185 gint months,
186 gint days,
187 gint hours,
188 gint minutes,
189 gdouble seconds);
190
191GLIB_AVAILABLE_IN_ALL
192gint g_date_time_compare (gconstpointer dt1,
193 gconstpointer dt2);
194GLIB_AVAILABLE_IN_ALL
195GTimeSpan g_date_time_difference (GDateTime *end,
196 GDateTime *begin);
197GLIB_AVAILABLE_IN_ALL
198guint g_date_time_hash (gconstpointer datetime);
199GLIB_AVAILABLE_IN_ALL
200gboolean g_date_time_equal (gconstpointer dt1,
201 gconstpointer dt2);
202
203GLIB_AVAILABLE_IN_ALL
204void g_date_time_get_ymd (GDateTime *datetime,
205 gint *year,
206 gint *month,
207 gint *day);
208
209GLIB_AVAILABLE_IN_ALL
210gint g_date_time_get_year (GDateTime *datetime);
211GLIB_AVAILABLE_IN_ALL
212gint g_date_time_get_month (GDateTime *datetime);
213GLIB_AVAILABLE_IN_ALL
214gint g_date_time_get_day_of_month (GDateTime *datetime);
215
216GLIB_AVAILABLE_IN_ALL
217gint g_date_time_get_week_numbering_year (GDateTime *datetime);
218GLIB_AVAILABLE_IN_ALL
219gint g_date_time_get_week_of_year (GDateTime *datetime);
220GLIB_AVAILABLE_IN_ALL
221gint g_date_time_get_day_of_week (GDateTime *datetime);
222
223GLIB_AVAILABLE_IN_ALL
224gint g_date_time_get_day_of_year (GDateTime *datetime);
225
226GLIB_AVAILABLE_IN_ALL
227gint g_date_time_get_hour (GDateTime *datetime);
228GLIB_AVAILABLE_IN_ALL
229gint g_date_time_get_minute (GDateTime *datetime);
230GLIB_AVAILABLE_IN_ALL
231gint g_date_time_get_second (GDateTime *datetime);
232GLIB_AVAILABLE_IN_ALL
233gint g_date_time_get_microsecond (GDateTime *datetime);
234GLIB_AVAILABLE_IN_ALL
235gdouble g_date_time_get_seconds (GDateTime *datetime);
236
237GLIB_AVAILABLE_IN_ALL
238gint64 g_date_time_to_unix (GDateTime *datetime);
239GLIB_AVAILABLE_IN_ALL
240gboolean g_date_time_to_timeval (GDateTime *datetime,
241 GTimeVal *tv);
242
243GLIB_AVAILABLE_IN_ALL
244GTimeSpan g_date_time_get_utc_offset (GDateTime *datetime);
245GLIB_AVAILABLE_IN_ALL
246const gchar * g_date_time_get_timezone_abbreviation (GDateTime *datetime);
247GLIB_AVAILABLE_IN_ALL
248gboolean g_date_time_is_daylight_savings (GDateTime *datetime);
249
250GLIB_AVAILABLE_IN_ALL
251GDateTime * g_date_time_to_timezone (GDateTime *datetime,
252 GTimeZone *tz);
253GLIB_AVAILABLE_IN_ALL
254GDateTime * g_date_time_to_local (GDateTime *datetime);
255GLIB_AVAILABLE_IN_ALL
256GDateTime * g_date_time_to_utc (GDateTime *datetime);
257
258GLIB_AVAILABLE_IN_ALL
259gchar * g_date_time_format (GDateTime *datetime,
260 const gchar *format) G_GNUC_MALLOC;
261
262G_END_DECLS
263
264#endif /* __G_DATE_TIME_H__ */
265