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