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