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 * An opaque structure that represents a date and time, including a time zone.
93 *
94 * Since: 2.26
95 */
96typedef struct _GDateTime GDateTime;
97
98GLIB_AVAILABLE_IN_ALL
99void g_date_time_unref (GDateTime *datetime);
100GLIB_AVAILABLE_IN_ALL
101GDateTime * g_date_time_ref (GDateTime *datetime);
102
103GLIB_AVAILABLE_IN_ALL
104GDateTime * g_date_time_new_now (GTimeZone *tz);
105GLIB_AVAILABLE_IN_ALL
106GDateTime * g_date_time_new_now_local (void);
107GLIB_AVAILABLE_IN_ALL
108GDateTime * g_date_time_new_now_utc (void);
109
110GLIB_AVAILABLE_IN_ALL
111GDateTime * g_date_time_new_from_unix_local (gint64 t);
112GLIB_AVAILABLE_IN_ALL
113GDateTime * g_date_time_new_from_unix_utc (gint64 t);
114
115G_GNUC_BEGIN_IGNORE_DEPRECATIONS
116GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_local)
117GDateTime * g_date_time_new_from_timeval_local (const GTimeVal *tv);
118GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_utc)
119GDateTime * g_date_time_new_from_timeval_utc (const GTimeVal *tv);
120G_GNUC_END_IGNORE_DEPRECATIONS
121
122GLIB_AVAILABLE_IN_2_56
123GDateTime * g_date_time_new_from_iso8601 (const gchar *text,
124 GTimeZone *default_tz);
125
126GLIB_AVAILABLE_IN_ALL
127GDateTime * g_date_time_new (GTimeZone *tz,
128 gint year,
129 gint month,
130 gint day,
131 gint hour,
132 gint minute,
133 gdouble seconds);
134GLIB_AVAILABLE_IN_ALL
135GDateTime * g_date_time_new_local (gint year,
136 gint month,
137 gint day,
138 gint hour,
139 gint minute,
140 gdouble seconds);
141GLIB_AVAILABLE_IN_ALL
142GDateTime * g_date_time_new_utc (gint year,
143 gint month,
144 gint day,
145 gint hour,
146 gint minute,
147 gdouble seconds);
148
149GLIB_AVAILABLE_IN_ALL
150G_GNUC_WARN_UNUSED_RESULT
151GDateTime * g_date_time_add (GDateTime *datetime,
152 GTimeSpan timespan);
153
154GLIB_AVAILABLE_IN_ALL
155G_GNUC_WARN_UNUSED_RESULT
156GDateTime * g_date_time_add_years (GDateTime *datetime,
157 gint years);
158GLIB_AVAILABLE_IN_ALL
159G_GNUC_WARN_UNUSED_RESULT
160GDateTime * g_date_time_add_months (GDateTime *datetime,
161 gint months);
162GLIB_AVAILABLE_IN_ALL
163G_GNUC_WARN_UNUSED_RESULT
164GDateTime * g_date_time_add_weeks (GDateTime *datetime,
165 gint weeks);
166GLIB_AVAILABLE_IN_ALL
167G_GNUC_WARN_UNUSED_RESULT
168GDateTime * g_date_time_add_days (GDateTime *datetime,
169 gint days);
170
171GLIB_AVAILABLE_IN_ALL
172G_GNUC_WARN_UNUSED_RESULT
173GDateTime * g_date_time_add_hours (GDateTime *datetime,
174 gint hours);
175GLIB_AVAILABLE_IN_ALL
176G_GNUC_WARN_UNUSED_RESULT
177GDateTime * g_date_time_add_minutes (GDateTime *datetime,
178 gint minutes);
179GLIB_AVAILABLE_IN_ALL
180G_GNUC_WARN_UNUSED_RESULT
181GDateTime * g_date_time_add_seconds (GDateTime *datetime,
182 gdouble seconds);
183
184GLIB_AVAILABLE_IN_ALL
185G_GNUC_WARN_UNUSED_RESULT
186GDateTime * g_date_time_add_full (GDateTime *datetime,
187 gint years,
188 gint months,
189 gint days,
190 gint hours,
191 gint minutes,
192 gdouble seconds);
193
194GLIB_AVAILABLE_IN_ALL
195gint g_date_time_compare (gconstpointer dt1,
196 gconstpointer dt2);
197GLIB_AVAILABLE_IN_ALL
198GTimeSpan g_date_time_difference (GDateTime *end,
199 GDateTime *begin);
200GLIB_AVAILABLE_IN_ALL
201guint g_date_time_hash (gconstpointer datetime);
202GLIB_AVAILABLE_IN_ALL
203gboolean g_date_time_equal (gconstpointer dt1,
204 gconstpointer dt2);
205
206GLIB_AVAILABLE_IN_ALL
207void g_date_time_get_ymd (GDateTime *datetime,
208 gint *year,
209 gint *month,
210 gint *day);
211
212GLIB_AVAILABLE_IN_ALL
213gint g_date_time_get_year (GDateTime *datetime);
214GLIB_AVAILABLE_IN_ALL
215gint g_date_time_get_month (GDateTime *datetime);
216GLIB_AVAILABLE_IN_ALL
217gint g_date_time_get_day_of_month (GDateTime *datetime);
218
219GLIB_AVAILABLE_IN_ALL
220gint g_date_time_get_week_numbering_year (GDateTime *datetime);
221GLIB_AVAILABLE_IN_ALL
222gint g_date_time_get_week_of_year (GDateTime *datetime);
223GLIB_AVAILABLE_IN_ALL
224gint g_date_time_get_day_of_week (GDateTime *datetime);
225
226GLIB_AVAILABLE_IN_ALL
227gint g_date_time_get_day_of_year (GDateTime *datetime);
228
229GLIB_AVAILABLE_IN_ALL
230gint g_date_time_get_hour (GDateTime *datetime);
231GLIB_AVAILABLE_IN_ALL
232gint g_date_time_get_minute (GDateTime *datetime);
233GLIB_AVAILABLE_IN_ALL
234gint g_date_time_get_second (GDateTime *datetime);
235GLIB_AVAILABLE_IN_ALL
236gint g_date_time_get_microsecond (GDateTime *datetime);
237GLIB_AVAILABLE_IN_ALL
238gdouble g_date_time_get_seconds (GDateTime *datetime);
239
240GLIB_AVAILABLE_IN_ALL
241gint64 g_date_time_to_unix (GDateTime *datetime);
242G_GNUC_BEGIN_IGNORE_DEPRECATIONS
243GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_to_unix)
244gboolean g_date_time_to_timeval (GDateTime *datetime,
245 GTimeVal *tv);
246G_GNUC_END_IGNORE_DEPRECATIONS
247
248GLIB_AVAILABLE_IN_ALL
249GTimeSpan g_date_time_get_utc_offset (GDateTime *datetime);
250GLIB_AVAILABLE_IN_2_58
251GTimeZone * g_date_time_get_timezone (GDateTime *datetime);
252GLIB_AVAILABLE_IN_ALL
253const gchar * g_date_time_get_timezone_abbreviation (GDateTime *datetime);
254GLIB_AVAILABLE_IN_ALL
255gboolean g_date_time_is_daylight_savings (GDateTime *datetime);
256
257GLIB_AVAILABLE_IN_ALL
258GDateTime * g_date_time_to_timezone (GDateTime *datetime,
259 GTimeZone *tz);
260GLIB_AVAILABLE_IN_ALL
261GDateTime * g_date_time_to_local (GDateTime *datetime);
262GLIB_AVAILABLE_IN_ALL
263GDateTime * g_date_time_to_utc (GDateTime *datetime);
264
265GLIB_AVAILABLE_IN_ALL
266gchar * g_date_time_format (GDateTime *datetime,
267 const gchar *format) G_GNUC_MALLOC;
268GLIB_AVAILABLE_IN_2_62
269gchar * g_date_time_format_iso8601 (GDateTime *datetime) G_GNUC_MALLOC;
270
271G_END_DECLS
272
273#endif /* __G_DATE_TIME_H__ */
274

source code of include/glib-2.0/glib/gdatetime.h