Merge remote branch 'gvdb/master'
[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
35 G_BEGIN_DECLS
36
37 /**
38  * G_TIME_SPAN_DAY:
39  *
40  * Evaluates to a time span of one day.
41  *
42  * Since: 2.26
43  */
44 #define G_TIME_SPAN_DAY                 (G_GINT64_CONSTANT (86400000000))
45
46 /**
47  * G_TIME_SPAN_HOUR:
48  *
49  * Evaluates to a time span of one hour.
50  *
51  * Since: 2.26
52  */
53 #define G_TIME_SPAN_HOUR                (G_GINT64_CONSTANT (3600000000))
54
55 /**
56  * G_TIME_SPAN_MINUTE:
57  *
58  * Evaluates to a time span of one minute.
59  *
60  * Since: 2.26
61  */
62 #define G_TIME_SPAN_MINUTE              (G_GINT64_CONSTANT (60000000))
63
64 /**
65  * G_TIME_SPAN_SECOND:
66  *
67  * Evaluates to a time span of one second.
68  *
69  * Since: 2.26
70  */
71 #define G_TIME_SPAN_SECOND              (G_GINT64_CONSTANT (1000000))
72
73 /**
74  * G_TIME_SPAN_MILLISECOND:
75  *
76  * Evaluates to a time span of one millisecond.
77  *
78  * Since: 2.26
79  */
80 #define G_TIME_SPAN_MILLISECOND         (G_GINT64_CONSTANT (1000))
81
82 /**
83  * GTimeSpan:
84  *
85  * A value representing an interval of time, in microseconds.
86  *
87  * Since: 2.26
88  */
89 typedef gint64 GTimeSpan;
90
91 /**
92  * GDateTime:
93  *
94  * <structname>GDateTime</structname> is an opaque structure whose members
95  * cannot be accessed directly.
96  *
97  * Since: 2.26
98  */
99 typedef struct _GDateTime GDateTime;
100
101 void                    g_date_time_unref                               (GDateTime      *datetime);
102 GDateTime *             g_date_time_ref                                 (GDateTime      *datetime);
103
104 GDateTime *             g_date_time_new_now                             (GTimeZone      *tz);
105 GDateTime *             g_date_time_new_now_local                       (void);
106 GDateTime *             g_date_time_new_now_utc                         (void);
107
108 GDateTime *             g_date_time_new_from_unix_local                 (gint64          t);
109 GDateTime *             g_date_time_new_from_unix_utc                   (gint64          t);
110
111 GDateTime *             g_date_time_new_from_timeval_local              (const GTimeVal *tv);
112 GDateTime *             g_date_time_new_from_timeval_utc                (const GTimeVal *tv);
113
114 GDateTime *             g_date_time_new                                 (GTimeZone      *tz,
115                                                                          gint            year,
116                                                                          gint            month,
117                                                                          gint            day,
118                                                                          gint            hour,
119                                                                          gint            minute,
120                                                                          gdouble         seconds);
121 GDateTime *             g_date_time_new_local                           (gint            year,
122                                                                          gint            month,
123                                                                          gint            day,
124                                                                          gint            hour,
125                                                                          gint            minute,
126                                                                          gdouble         seconds);
127 GDateTime *             g_date_time_new_utc                             (gint            year,
128                                                                          gint            month,
129                                                                          gint            day,
130                                                                          gint            hour,
131                                                                          gint            minute,
132                                                                          gdouble         seconds);
133
134 G_GNUC_WARN_UNUSED_RESULT
135 GDateTime *             g_date_time_add                                 (GDateTime      *datetime,
136                                                                          GTimeSpan       timespan);
137
138 G_GNUC_WARN_UNUSED_RESULT
139 GDateTime *             g_date_time_add_years                           (GDateTime      *datetime,
140                                                                          gint            years);
141 G_GNUC_WARN_UNUSED_RESULT
142 GDateTime *             g_date_time_add_months                          (GDateTime      *datetime,
143                                                                          gint            months);
144 G_GNUC_WARN_UNUSED_RESULT
145 GDateTime *             g_date_time_add_weeks                           (GDateTime      *datetime,
146                                                                          gint            weeks);
147 G_GNUC_WARN_UNUSED_RESULT
148 GDateTime *             g_date_time_add_days                            (GDateTime      *datetime,
149                                                                          gint            days);
150
151 G_GNUC_WARN_UNUSED_RESULT
152 GDateTime *             g_date_time_add_hours                           (GDateTime      *datetime,
153                                                                          gint            hours);
154 G_GNUC_WARN_UNUSED_RESULT
155 GDateTime *             g_date_time_add_minutes                         (GDateTime      *datetime,
156                                                                          gint            minutes);
157 G_GNUC_WARN_UNUSED_RESULT
158 GDateTime *             g_date_time_add_seconds                         (GDateTime      *datetime,
159                                                                          gdouble         seconds);
160
161 G_GNUC_WARN_UNUSED_RESULT
162 GDateTime *             g_date_time_add_full                            (GDateTime      *datetime,
163                                                                          gint            years,
164                                                                          gint            months,
165                                                                          gint            days,
166                                                                          gint            hours,
167                                                                          gint            minutes,
168                                                                          gdouble         seconds);
169
170 gint                    g_date_time_compare                             (gconstpointer   dt1,
171                                                                          gconstpointer   dt2);
172 GTimeSpan               g_date_time_difference                          (GDateTime      *end,
173                                                                          GDateTime      *begin);
174 guint                   g_date_time_hash                                (gconstpointer   datetime);
175 gboolean                g_date_time_equal                               (gconstpointer   dt1,
176                                                                          gconstpointer   dt2);
177
178 void                    g_date_time_get_ymd                             (GDateTime      *datetime,
179                                                                          gint           *year,
180                                                                          gint           *month,
181                                                                          gint           *day);
182
183 gint                    g_date_time_get_year                            (GDateTime      *datetime);
184 gint                    g_date_time_get_month                           (GDateTime      *datetime);
185 gint                    g_date_time_get_day_of_month                    (GDateTime      *datetime);
186
187 gint                    g_date_time_get_week_numbering_year             (GDateTime      *datetime);
188 gint                    g_date_time_get_week_of_year                    (GDateTime      *datetime);
189 gint                    g_date_time_get_day_of_week                     (GDateTime      *datetime);
190
191 gint                    g_date_time_get_day_of_year                     (GDateTime      *datetime);
192
193 gint                    g_date_time_get_hour                            (GDateTime      *datetime);
194 gint                    g_date_time_get_minute                          (GDateTime      *datetime);
195 gint                    g_date_time_get_second                          (GDateTime      *datetime);
196 gint                    g_date_time_get_microsecond                     (GDateTime      *datetime);
197 gdouble                 g_date_time_get_seconds                         (GDateTime      *datetime);
198
199 gint64                  g_date_time_to_unix                             (GDateTime      *datetime);
200 gboolean                g_date_time_to_timeval                          (GDateTime      *datetime,
201                                                                          GTimeVal       *tv);
202
203 GTimeSpan               g_date_time_get_utc_offset                      (GDateTime      *datetime);
204 const gchar *           g_date_time_get_timezone_abbreviation           (GDateTime      *datetime);
205 gboolean                g_date_time_is_daylight_savings                 (GDateTime      *datetime);
206
207 GDateTime *             g_date_time_to_timezone                         (GDateTime      *datetime,
208                                                                          GTimeZone      *tz);
209 GDateTime *             g_date_time_to_local                            (GDateTime      *datetime);
210 GDateTime *             g_date_time_to_utc                              (GDateTime      *datetime);
211
212 gchar *                 g_date_time_format                              (GDateTime      *datetime,
213                                                                          const gchar    *format) G_GNUC_MALLOC;
214
215 G_END_DECLS
216
217 #endif /* __G_DATE_TIME_H__ */