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 License
16 * along with this library; if not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Christian Hergert <chris@dronelabs.com>
19 * Thiago Santos <thiago.sousa.santos@collabora.co.uk>
20 * Emmanuele Bassi <ebassi@linux.intel.com>
21 * Ryan Lortie <desrt@desrt.ca>
22 */
23
24#ifndef __G_DATE_TIME_H__
25#define __G_DATE_TIME_H__
26
27#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
28#error "Only <glib.h> can be included directly."
29#endif
30
31#include <glib/gtimezone.h>
32
33G_BEGIN_DECLS
34
35/**
36 * G_TIME_SPAN_DAY:
37 *
38 * Evaluates to a time span of one day.
39 *
40 * Since: 2.26
41 */
42#define G_TIME_SPAN_DAY (G_GINT64_CONSTANT (86400000000))
43
44/**
45 * G_TIME_SPAN_HOUR:
46 *
47 * Evaluates to a time span of one hour.
48 *
49 * Since: 2.26
50 */
51#define G_TIME_SPAN_HOUR (G_GINT64_CONSTANT (3600000000))
52
53/**
54 * G_TIME_SPAN_MINUTE:
55 *
56 * Evaluates to a time span of one minute.
57 *
58 * Since: 2.26
59 */
60#define G_TIME_SPAN_MINUTE (G_GINT64_CONSTANT (60000000))
61
62/**
63 * G_TIME_SPAN_SECOND:
64 *
65 * Evaluates to a time span of one second.
66 *
67 * Since: 2.26
68 */
69#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT (1000000))
70
71/**
72 * G_TIME_SPAN_MILLISECOND:
73 *
74 * Evaluates to a time span of one millisecond.
75 *
76 * Since: 2.26
77 */
78#define G_TIME_SPAN_MILLISECOND (G_GINT64_CONSTANT (1000))
79
80/**
81 * GTimeSpan:
82 *
83 * A value representing an interval of time, in microseconds.
84 *
85 * Since: 2.26
86 */
87typedef gint64 GTimeSpan;
88
89/**
90 * GDateTime:
91 *
92 * `GDateTime` is an opaque structure whose members
93 * cannot be accessed directly.
94 *
95 * Since: 2.26
96 */
97typedef struct _GDateTime GDateTime;
98
99GLIB_AVAILABLE_IN_ALL
100void g_date_time_unref (GDateTime *datetime);
101GLIB_AVAILABLE_IN_ALL
102GDateTime * g_date_time_ref (GDateTime *datetime);
103
104GLIB_AVAILABLE_IN_ALL
105GDateTime * g_date_time_new_now (GTimeZone *tz);
106GLIB_AVAILABLE_IN_ALL
107GDateTime * g_date_time_new_now_local (void);
108GLIB_AVAILABLE_IN_ALL
109GDateTime * g_date_time_new_now_utc (void);
110
111GLIB_AVAILABLE_IN_ALL
112GDateTime * g_date_time_new_from_unix_local (gint64 t);
113GLIB_AVAILABLE_IN_ALL
114GDateTime * g_date_time_new_from_unix_utc (gint64 t);
115
116G_GNUC_BEGIN_IGNORE_DEPRECATIONS
117GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_local)
118GDateTime * g_date_time_new_from_timeval_local (const GTimeVal *tv);
119GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_utc)
120GDateTime * g_date_time_new_from_timeval_utc (const GTimeVal *tv);
121G_GNUC_END_IGNORE_DEPRECATIONS
122
123GLIB_AVAILABLE_IN_2_56
124GDateTime * g_date_time_new_from_iso8601 (const gchar *text,
125 GTimeZone *default_tz);
126
127GLIB_AVAILABLE_IN_ALL
128GDateTime * g_date_time_new (GTimeZone *tz,
129 gint year,
130 gint month,
131 gint day,
132 gint hour,
133 gint minute,
134 gdouble seconds);
135GLIB_AVAILABLE_IN_ALL
136GDateTime * g_date_time_new_local (gint year,
137 gint month,
138 gint day,
139 gint hour,
140 gint minute,
141 gdouble seconds);
142GLIB_AVAILABLE_IN_ALL
143GDateTime * g_date_time_new_utc (gint year,
144 gint month,
145 gint day,
146 gint hour,
147 gint minute,
148 gdouble seconds);
149
150GLIB_AVAILABLE_IN_ALL
151G_GNUC_WARN_UNUSED_RESULT
152GDateTime * g_date_time_add (GDateTime *datetime,
153 GTimeSpan timespan);
154
155GLIB_AVAILABLE_IN_ALL
156G_GNUC_WARN_UNUSED_RESULT
157GDateTime * g_date_time_add_years (GDateTime *datetime,
158 gint years);
159GLIB_AVAILABLE_IN_ALL
160G_GNUC_WARN_UNUSED_RESULT
161GDateTime * g_date_time_add_months (GDateTime *datetime,
162 gint months);
163GLIB_AVAILABLE_IN_ALL
164G_GNUC_WARN_UNUSED_RESULT
165GDateTime * g_date_time_add_weeks (GDateTime *datetime,
166 gint weeks);
167GLIB_AVAILABLE_IN_ALL
168G_GNUC_WARN_UNUSED_RESULT
169GDateTime * g_date_time_add_days (GDateTime *datetime,
170 gint days);
171
172GLIB_AVAILABLE_IN_ALL
173G_GNUC_WARN_UNUSED_RESULT
174GDateTime * g_date_time_add_hours (GDateTime *datetime,
175 gint hours);
176GLIB_AVAILABLE_IN_ALL
177G_GNUC_WARN_UNUSED_RESULT
178GDateTime * g_date_time_add_minutes (GDateTime *datetime,
179 gint minutes);
180GLIB_AVAILABLE_IN_ALL
181G_GNUC_WARN_UNUSED_RESULT
182GDateTime * g_date_time_add_seconds (GDateTime *datetime,
183 gdouble seconds);
184
185GLIB_AVAILABLE_IN_ALL
186G_GNUC_WARN_UNUSED_RESULT
187GDateTime * g_date_time_add_full (GDateTime *datetime,
188 gint years,
189 gint months,
190 gint days,
191 gint hours,
192 gint minutes,
193 gdouble seconds);
194
195GLIB_AVAILABLE_IN_ALL
196gint g_date_time_compare (gconstpointer dt1,
197 gconstpointer dt2);
198GLIB_AVAILABLE_IN_ALL
199GTimeSpan g_date_time_difference (GDateTime *end,
200 GDateTime *begin);
201GLIB_AVAILABLE_IN_ALL
202guint g_date_time_hash (gconstpointer datetime);
203GLIB_AVAILABLE_IN_ALL
204gboolean g_date_time_equal (gconstpointer dt1,
205 gconstpointer dt2);
206
207GLIB_AVAILABLE_IN_ALL
208void g_date_time_get_ymd (GDateTime *datetime,
209 gint *year,
210 gint *month,
211 gint *day);
212
213GLIB_AVAILABLE_IN_ALL
214gint g_date_time_get_year (GDateTime *datetime);
215GLIB_AVAILABLE_IN_ALL
216gint g_date_time_get_month (GDateTime *datetime);
217GLIB_AVAILABLE_IN_ALL
218gint g_date_time_get_day_of_month (GDateTime *datetime);
219
220GLIB_AVAILABLE_IN_ALL
221gint g_date_time_get_week_numbering_year (GDateTime *datetime);
222GLIB_AVAILABLE_IN_ALL
223gint g_date_time_get_week_of_year (GDateTime *datetime);
224GLIB_AVAILABLE_IN_ALL
225gint g_date_time_get_day_of_week (GDateTime *datetime);
226
227GLIB_AVAILABLE_IN_ALL
228gint g_date_time_get_day_of_year (GDateTime *datetime);
229
230GLIB_AVAILABLE_IN_ALL
231gint g_date_time_get_hour (GDateTime *datetime);
232GLIB_AVAILABLE_IN_ALL
233gint g_date_time_get_minute (GDateTime *datetime);
234GLIB_AVAILABLE_IN_ALL
235gint g_date_time_get_second (GDateTime *datetime);
236GLIB_AVAILABLE_IN_ALL
237gint g_date_time_get_microsecond (GDateTime *datetime);
238GLIB_AVAILABLE_IN_ALL
239gdouble g_date_time_get_seconds (GDateTime *datetime);
240
241GLIB_AVAILABLE_IN_ALL
242gint64 g_date_time_to_unix (GDateTime *datetime);
243G_GNUC_BEGIN_IGNORE_DEPRECATIONS
244GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_to_unix)
245gboolean g_date_time_to_timeval (GDateTime *datetime,
246 GTimeVal *tv);
247G_GNUC_END_IGNORE_DEPRECATIONS
248
249GLIB_AVAILABLE_IN_ALL
250GTimeSpan g_date_time_get_utc_offset (GDateTime *datetime);
251GLIB_AVAILABLE_IN_2_58
252GTimeZone * g_date_time_get_timezone (GDateTime *datetime);
253GLIB_AVAILABLE_IN_ALL
254const gchar * g_date_time_get_timezone_abbreviation (GDateTime *datetime);
255GLIB_AVAILABLE_IN_ALL
256gboolean g_date_time_is_daylight_savings (GDateTime *datetime);
257
258GLIB_AVAILABLE_IN_ALL
259GDateTime * g_date_time_to_timezone (GDateTime *datetime,
260 GTimeZone *tz);
261GLIB_AVAILABLE_IN_ALL
262GDateTime * g_date_time_to_local (GDateTime *datetime);
263GLIB_AVAILABLE_IN_ALL
264GDateTime * g_date_time_to_utc (GDateTime *datetime);
265
266GLIB_AVAILABLE_IN_ALL
267gchar * g_date_time_format (GDateTime *datetime,
268 const gchar *format) G_GNUC_MALLOC;
269GLIB_AVAILABLE_IN_2_62
270gchar * g_date_time_format_iso8601 (GDateTime *datetime) G_GNUC_MALLOC;
271
272G_END_DECLS
273
274#endif /* __G_DATE_TIME_H__ */
275

source code of gtk/subprojects/glib/glib/gdatetime.h