2 * Copyright (C) 2009-2010 Christian Hergert <chris@dronelabs.com>
3 * Copyright © 2010 Codethink Limited
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.
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.
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/>.
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>
24 #ifndef __G_DATE_TIME_H__
25 #define __G_DATE_TIME_H__
27 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
28 #error "Only <glib.h> can be included directly."
31 #include <glib/gtimezone.h>
38 * Evaluates to a time span of one day.
42 #define G_TIME_SPAN_DAY (G_GINT64_CONSTANT (86400000000))
47 * Evaluates to a time span of one hour.
51 #define G_TIME_SPAN_HOUR (G_GINT64_CONSTANT (3600000000))
56 * Evaluates to a time span of one minute.
60 #define G_TIME_SPAN_MINUTE (G_GINT64_CONSTANT (60000000))
65 * Evaluates to a time span of one second.
69 #define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT (1000000))
72 * G_TIME_SPAN_MILLISECOND:
74 * Evaluates to a time span of one millisecond.
78 #define G_TIME_SPAN_MILLISECOND (G_GINT64_CONSTANT (1000))
83 * A value representing an interval of time, in microseconds.
87 typedef gint64 GTimeSpan;
92 * `GDateTime` is an opaque structure whose members
93 * cannot be accessed directly.
97 typedef struct _GDateTime GDateTime;
100 void g_date_time_unref (GDateTime *datetime);
101 GLIB_AVAILABLE_IN_ALL
102 GDateTime * g_date_time_ref (GDateTime *datetime);
104 GLIB_AVAILABLE_IN_ALL
105 GDateTime * g_date_time_new_now (GTimeZone *tz);
106 GLIB_AVAILABLE_IN_ALL
107 GDateTime * g_date_time_new_now_local (void);
108 GLIB_AVAILABLE_IN_ALL
109 GDateTime * g_date_time_new_now_utc (void);
111 GLIB_AVAILABLE_IN_ALL
112 GDateTime * g_date_time_new_from_unix_local (gint64 t);
113 GLIB_AVAILABLE_IN_ALL
114 GDateTime * g_date_time_new_from_unix_utc (gint64 t);
116 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
117 GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_local)
118 GDateTime * g_date_time_new_from_timeval_local (const GTimeVal *tv);
119 GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_utc)
120 GDateTime * g_date_time_new_from_timeval_utc (const GTimeVal *tv);
121 G_GNUC_END_IGNORE_DEPRECATIONS
123 GLIB_AVAILABLE_IN_2_56
124 GDateTime * g_date_time_new_from_iso8601 (const gchar *text,
125 GTimeZone *default_tz);
127 GLIB_AVAILABLE_IN_ALL
128 GDateTime * g_date_time_new (GTimeZone *tz,
135 GLIB_AVAILABLE_IN_ALL
136 GDateTime * g_date_time_new_local (gint year,
142 GLIB_AVAILABLE_IN_ALL
143 GDateTime * g_date_time_new_utc (gint year,
150 GLIB_AVAILABLE_IN_ALL
151 G_GNUC_WARN_UNUSED_RESULT
152 GDateTime * g_date_time_add (GDateTime *datetime,
155 GLIB_AVAILABLE_IN_ALL
156 G_GNUC_WARN_UNUSED_RESULT
157 GDateTime * g_date_time_add_years (GDateTime *datetime,
159 GLIB_AVAILABLE_IN_ALL
160 G_GNUC_WARN_UNUSED_RESULT
161 GDateTime * g_date_time_add_months (GDateTime *datetime,
163 GLIB_AVAILABLE_IN_ALL
164 G_GNUC_WARN_UNUSED_RESULT
165 GDateTime * g_date_time_add_weeks (GDateTime *datetime,
167 GLIB_AVAILABLE_IN_ALL
168 G_GNUC_WARN_UNUSED_RESULT
169 GDateTime * g_date_time_add_days (GDateTime *datetime,
172 GLIB_AVAILABLE_IN_ALL
173 G_GNUC_WARN_UNUSED_RESULT
174 GDateTime * g_date_time_add_hours (GDateTime *datetime,
176 GLIB_AVAILABLE_IN_ALL
177 G_GNUC_WARN_UNUSED_RESULT
178 GDateTime * g_date_time_add_minutes (GDateTime *datetime,
180 GLIB_AVAILABLE_IN_ALL
181 G_GNUC_WARN_UNUSED_RESULT
182 GDateTime * g_date_time_add_seconds (GDateTime *datetime,
185 GLIB_AVAILABLE_IN_ALL
186 G_GNUC_WARN_UNUSED_RESULT
187 GDateTime * g_date_time_add_full (GDateTime *datetime,
195 GLIB_AVAILABLE_IN_ALL
196 gint g_date_time_compare (gconstpointer dt1,
198 GLIB_AVAILABLE_IN_ALL
199 GTimeSpan g_date_time_difference (GDateTime *end,
201 GLIB_AVAILABLE_IN_ALL
202 guint g_date_time_hash (gconstpointer datetime);
203 GLIB_AVAILABLE_IN_ALL
204 gboolean g_date_time_equal (gconstpointer dt1,
207 GLIB_AVAILABLE_IN_ALL
208 void g_date_time_get_ymd (GDateTime *datetime,
213 GLIB_AVAILABLE_IN_ALL
214 gint g_date_time_get_year (GDateTime *datetime);
215 GLIB_AVAILABLE_IN_ALL
216 gint g_date_time_get_month (GDateTime *datetime);
217 GLIB_AVAILABLE_IN_ALL
218 gint g_date_time_get_day_of_month (GDateTime *datetime);
220 GLIB_AVAILABLE_IN_ALL
221 gint g_date_time_get_week_numbering_year (GDateTime *datetime);
222 GLIB_AVAILABLE_IN_ALL
223 gint g_date_time_get_week_of_year (GDateTime *datetime);
224 GLIB_AVAILABLE_IN_ALL
225 gint g_date_time_get_day_of_week (GDateTime *datetime);
227 GLIB_AVAILABLE_IN_ALL
228 gint g_date_time_get_day_of_year (GDateTime *datetime);
230 GLIB_AVAILABLE_IN_ALL
231 gint g_date_time_get_hour (GDateTime *datetime);
232 GLIB_AVAILABLE_IN_ALL
233 gint g_date_time_get_minute (GDateTime *datetime);
234 GLIB_AVAILABLE_IN_ALL
235 gint g_date_time_get_second (GDateTime *datetime);
236 GLIB_AVAILABLE_IN_ALL
237 gint g_date_time_get_microsecond (GDateTime *datetime);
238 GLIB_AVAILABLE_IN_ALL
239 gdouble g_date_time_get_seconds (GDateTime *datetime);
241 GLIB_AVAILABLE_IN_ALL
242 gint64 g_date_time_to_unix (GDateTime *datetime);
243 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
244 GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_to_unix)
245 gboolean g_date_time_to_timeval (GDateTime *datetime,
247 G_GNUC_END_IGNORE_DEPRECATIONS
249 GLIB_AVAILABLE_IN_ALL
250 GTimeSpan g_date_time_get_utc_offset (GDateTime *datetime);
251 GLIB_AVAILABLE_IN_2_58
252 GTimeZone * g_date_time_get_timezone (GDateTime *datetime);
253 GLIB_AVAILABLE_IN_ALL
254 const gchar * g_date_time_get_timezone_abbreviation (GDateTime *datetime);
255 GLIB_AVAILABLE_IN_ALL
256 gboolean g_date_time_is_daylight_savings (GDateTime *datetime);
258 GLIB_AVAILABLE_IN_ALL
259 GDateTime * g_date_time_to_timezone (GDateTime *datetime,
261 GLIB_AVAILABLE_IN_ALL
262 GDateTime * g_date_time_to_local (GDateTime *datetime);
263 GLIB_AVAILABLE_IN_ALL
264 GDateTime * g_date_time_to_utc (GDateTime *datetime);
266 GLIB_AVAILABLE_IN_ALL
267 gchar * g_date_time_format (GDateTime *datetime,
268 const gchar *format) G_GNUC_MALLOC;
269 GLIB_AVAILABLE_IN_2_62
270 gchar * g_date_time_format_iso8601 (GDateTime *datetime) G_GNUC_MALLOC;
274 #endif /* __G_DATE_TIME_H__ */