gdatetime: Add g_date_time_source_new()
[platform/upstream/glib.git] / glib / gdatetime.h
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
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
18  * USA.
19  *
20  * Authors: Christian Hergert <chris@dronelabs.com>
21  *          Thiago Santos <thiago.sousa.santos@collabora.co.uk>
22  *          Emmanuele Bassi <ebassi@linux.intel.com>
23  *          Ryan Lortie <desrt@desrt.ca>
24  */
25
26 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
27 #error "Only <glib.h> can be included directly."
28 #endif
29
30 #ifndef __G_DATE_TIME_H__
31 #define __G_DATE_TIME_H__
32
33 #include <glib/gtimezone.h>
34 #include <glib/gmain.h>
35
36 G_BEGIN_DECLS
37
38 /**
39  * G_TIME_SPAN_DAY:
40  *
41  * Evaluates to a time span of one day.
42  *
43  * Since: 2.26
44  */
45 #define G_TIME_SPAN_DAY                 (G_GINT64_CONSTANT (86400000000))
46
47 /**
48  * G_TIME_SPAN_HOUR:
49  *
50  * Evaluates to a time span of one hour.
51  *
52  * Since: 2.26
53  */
54 #define G_TIME_SPAN_HOUR                (G_GINT64_CONSTANT (3600000000))
55
56 /**
57  * G_TIME_SPAN_MINUTE:
58  *
59  * Evaluates to a time span of one minute.
60  *
61  * Since: 2.26
62  */
63 #define G_TIME_SPAN_MINUTE              (G_GINT64_CONSTANT (60000000))
64
65 /**
66  * G_TIME_SPAN_SECOND:
67  *
68  * Evaluates to a time span of one second.
69  *
70  * Since: 2.26
71  */
72 #define G_TIME_SPAN_SECOND              (G_GINT64_CONSTANT (1000000))
73
74 /**
75  * G_TIME_SPAN_MILLISECOND:
76  *
77  * Evaluates to a time span of one millisecond.
78  *
79  * Since: 2.26
80  */
81 #define G_TIME_SPAN_MILLISECOND         (G_GINT64_CONSTANT (1000))
82
83 /**
84  * GTimeSpan:
85  *
86  * A value representing an interval of time, in microseconds.
87  *
88  * Since: 2.26
89  */
90 typedef gint64 GTimeSpan;
91
92 /**
93  * GDateTime:
94  *
95  * <structname>GDateTime</structname> is an opaque structure whose members
96  * cannot be accessed directly.
97  *
98  * Since: 2.26
99  */
100 typedef struct _GDateTime GDateTime;
101
102 void                    g_date_time_unref                               (GDateTime      *datetime);
103 GDateTime *             g_date_time_ref                                 (GDateTime      *datetime);
104
105 GDateTime *             g_date_time_new_now                             (GTimeZone      *tz);
106 GDateTime *             g_date_time_new_now_local                       (void);
107 GDateTime *             g_date_time_new_now_utc                         (void);
108
109 GDateTime *             g_date_time_new_from_unix_local                 (gint64          t);
110 GDateTime *             g_date_time_new_from_unix_utc                   (gint64          t);
111
112 GDateTime *             g_date_time_new_from_timeval_local              (const GTimeVal *tv);
113 GDateTime *             g_date_time_new_from_timeval_utc                (const GTimeVal *tv);
114
115 GDateTime *             g_date_time_new                                 (GTimeZone      *tz,
116                                                                          gint            year,
117                                                                          gint            month,
118                                                                          gint            day,
119                                                                          gint            hour,
120                                                                          gint            minute,
121                                                                          gdouble         seconds);
122 GDateTime *             g_date_time_new_local                           (gint            year,
123                                                                          gint            month,
124                                                                          gint            day,
125                                                                          gint            hour,
126                                                                          gint            minute,
127                                                                          gdouble         seconds);
128 GDateTime *             g_date_time_new_utc                             (gint            year,
129                                                                          gint            month,
130                                                                          gint            day,
131                                                                          gint            hour,
132                                                                          gint            minute,
133                                                                          gdouble         seconds);
134
135 G_GNUC_WARN_UNUSED_RESULT
136 GDateTime *             g_date_time_add                                 (GDateTime      *datetime,
137                                                                          GTimeSpan       timespan);
138
139 G_GNUC_WARN_UNUSED_RESULT
140 GDateTime *             g_date_time_add_years                           (GDateTime      *datetime,
141                                                                          gint            years);
142 G_GNUC_WARN_UNUSED_RESULT
143 GDateTime *             g_date_time_add_months                          (GDateTime      *datetime,
144                                                                          gint            months);
145 G_GNUC_WARN_UNUSED_RESULT
146 GDateTime *             g_date_time_add_weeks                           (GDateTime      *datetime,
147                                                                          gint            weeks);
148 G_GNUC_WARN_UNUSED_RESULT
149 GDateTime *             g_date_time_add_days                            (GDateTime      *datetime,
150                                                                          gint            days);
151
152 G_GNUC_WARN_UNUSED_RESULT
153 GDateTime *             g_date_time_add_hours                           (GDateTime      *datetime,
154                                                                          gint            hours);
155 G_GNUC_WARN_UNUSED_RESULT
156 GDateTime *             g_date_time_add_minutes                         (GDateTime      *datetime,
157                                                                          gint            minutes);
158 G_GNUC_WARN_UNUSED_RESULT
159 GDateTime *             g_date_time_add_seconds                         (GDateTime      *datetime,
160                                                                          gdouble         seconds);
161
162 G_GNUC_WARN_UNUSED_RESULT
163 GDateTime *             g_date_time_add_full                            (GDateTime      *datetime,
164                                                                          gint            years,
165                                                                          gint            months,
166                                                                          gint            days,
167                                                                          gint            hours,
168                                                                          gint            minutes,
169                                                                          gdouble         seconds);
170
171 gint                    g_date_time_compare                             (gconstpointer   dt1,
172                                                                          gconstpointer   dt2);
173 GTimeSpan               g_date_time_difference                          (GDateTime      *end,
174                                                                          GDateTime      *begin);
175 guint                   g_date_time_hash                                (gconstpointer   datetime);
176 gboolean                g_date_time_equal                               (gconstpointer   dt1,
177                                                                          gconstpointer   dt2);
178
179 void                    g_date_time_get_ymd                             (GDateTime      *datetime,
180                                                                          gint           *year,
181                                                                          gint           *month,
182                                                                          gint           *day);
183
184 gint                    g_date_time_get_year                            (GDateTime      *datetime);
185 gint                    g_date_time_get_month                           (GDateTime      *datetime);
186 gint                    g_date_time_get_day_of_month                    (GDateTime      *datetime);
187
188 gint                    g_date_time_get_week_numbering_year             (GDateTime      *datetime);
189 gint                    g_date_time_get_week_of_year                    (GDateTime      *datetime);
190 gint                    g_date_time_get_day_of_week                     (GDateTime      *datetime);
191
192 gint                    g_date_time_get_day_of_year                     (GDateTime      *datetime);
193
194 gint                    g_date_time_get_hour                            (GDateTime      *datetime);
195 gint                    g_date_time_get_minute                          (GDateTime      *datetime);
196 gint                    g_date_time_get_second                          (GDateTime      *datetime);
197 gint                    g_date_time_get_microsecond                     (GDateTime      *datetime);
198 gdouble                 g_date_time_get_seconds                         (GDateTime      *datetime);
199
200 gint64                  g_date_time_to_unix                             (GDateTime      *datetime);
201 gboolean                g_date_time_to_timeval                          (GDateTime      *datetime,
202                                                                          GTimeVal       *tv);
203
204 GTimeSpan               g_date_time_get_utc_offset                      (GDateTime      *datetime);
205 const gchar *           g_date_time_get_timezone_abbreviation           (GDateTime      *datetime);
206 gboolean                g_date_time_is_daylight_savings                 (GDateTime      *datetime);
207
208 GDateTime *             g_date_time_to_timezone                         (GDateTime      *datetime,
209                                                                          GTimeZone      *tz);
210 GDateTime *             g_date_time_to_local                            (GDateTime      *datetime);
211 GDateTime *             g_date_time_to_utc                              (GDateTime      *datetime);
212
213 gchar *                 g_date_time_format                              (GDateTime      *datetime,
214                                                                          const gchar    *format) G_GNUC_MALLOC;
215
216 GSource *               g_date_time_source_new                          (GDateTime      *datetime,
217                                                                          gboolean        cancel_on_set);
218 G_END_DECLS
219
220 #endif /* __G_DATE_TIME_H__ */