Remove excessive header includes
[glib.git] / glib / gdatetime.h
blob315f55821dddaea8acc0ff951f8141ae3a34ce90
1 /* gdatetime.h
3 * Copyright (C) 2009-2010 Christian Hergert <chris@dronelabs.com>
5 * This is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
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 USA
20 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
21 #error "Only <glib.h> can be included directly."
22 #endif
24 #ifndef __G_DATE_TIME_H__
25 #define __G_DATE_TIME_H__
27 #include <time.h>
28 #include <gtypes.h>
30 G_BEGIN_DECLS
32 /**
33 * G_TIME_SPAN_DAY:
35 * Evaluates to a time span of one day.
37 * Since: 2.26
39 #define G_TIME_SPAN_DAY (G_GINT64_CONSTANT (86400000000))
41 /**
42 * G_TIME_SPAN_HOUR:
44 * Evaluates to a time span of one hour.
46 * Since: 2.26
48 #define G_TIME_SPAN_HOUR (G_GINT64_CONSTANT (3600000000))
50 /**
51 * G_TIME_SPAN_MINUTE:
53 * Evaluates to a time span of one minute.
55 * Since: 2.26
57 #define G_TIME_SPAN_MINUTE (G_GINT64_CONSTANT (60000000))
59 /**
60 * G_TIME_SPAN_SECOND:
62 * Evaluates to a time span of one second.
64 * Since: 2.26
66 #define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT (1000000))
68 /**
69 * G_TIME_SPAN_MILLISECOND:
71 * Evaluates to a time span of one millisecond.
73 * Since: 2.26
75 #define G_TIME_SPAN_MILLISECOND (G_GINT64_CONSTANT (1000))
77 /**
78 * GDateTime:
80 * <structname>GDateTime</structname> is an opaque structure whose members
81 * cannot be accessed directly.
83 * Since: 2.26
85 typedef struct _GDateTime GDateTime;
87 /**
88 * GTimeSpan:
90 * A value representing an interval of time, in microseconds.
92 * Since: 2.26
94 typedef gint64 GTimeSpan;
96 GDateTime * g_date_time_new_now (void);
97 GDateTime * g_date_time_new_today (void);
98 GDateTime * g_date_time_new_utc_now (void);
99 GDateTime * g_date_time_new_from_date (gint year,
100 gint month,
101 gint day);
102 GDateTime * g_date_time_new_from_epoch (gint64 secs);
103 GDateTime * g_date_time_new_from_timeval (GTimeVal *tv);
104 GDateTime * g_date_time_new_full (gint year,
105 gint month,
106 gint day,
107 gint hour,
108 gint minute,
109 gint second,
110 const gchar *timezone);
112 GDateTime * g_date_time_copy (const GDateTime *datetime);
113 GDateTime * g_date_time_ref (GDateTime *datetime);
114 void g_date_time_unref (GDateTime *datetime);
116 GDateTime * g_date_time_add (const GDateTime *datetime,
117 GTimeSpan timespan);
118 GDateTime * g_date_time_add_days (const GDateTime *datetime,
119 gint days);
120 GDateTime * g_date_time_add_hours (const GDateTime *datetime,
121 gint hours);
122 GDateTime * g_date_time_add_milliseconds (const GDateTime *datetime,
123 gint milliseconds);
124 GDateTime * g_date_time_add_minutes (const GDateTime *datetime,
125 gint minutes);
126 GDateTime * g_date_time_add_months (const GDateTime *datetime,
127 gint months);
128 GDateTime * g_date_time_add_seconds (const GDateTime *datetime,
129 gint seconds);
130 GDateTime * g_date_time_add_weeks (const GDateTime *datetime,
131 gint weeks);
132 GDateTime * g_date_time_add_years (const GDateTime *datetime,
133 gint years);
134 GDateTime * g_date_time_add_full (const GDateTime *datetime,
135 gint years,
136 gint months,
137 gint days,
138 gint hours,
139 gint minutes,
140 gint seconds);
142 GDateTime * g_date_time_day (const GDateTime *datetime);
144 gint g_date_time_compare (gconstpointer dt1,
145 gconstpointer dt2);
146 gboolean g_date_time_equal (gconstpointer dt1,
147 gconstpointer dt2);
148 guint g_date_time_hash (gconstpointer datetime);
150 GTimeSpan g_date_time_difference (const GDateTime *begin,
151 const GDateTime *end);
153 void g_date_time_get_julian (const GDateTime *datetime,
154 gint *period,
155 gint *julian,
156 gint *hour,
157 gint *minute,
158 gint *second);
159 gint g_date_time_get_hour (const GDateTime *datetime);
160 gint g_date_time_get_minute (const GDateTime *datetime);
161 gint g_date_time_get_second (const GDateTime *datetime);
162 gint g_date_time_get_millisecond (const GDateTime *datetime);
163 gint g_date_time_get_microsecond (const GDateTime *datetime);
164 gint g_date_time_get_day_of_week (const GDateTime *datetime);
165 gint g_date_time_get_day_of_month (const GDateTime *datetime);
166 gint g_date_time_get_day_of_year (const GDateTime *datetime);
167 gint g_date_time_get_month (const GDateTime *datetime);
168 gint g_date_time_get_year (const GDateTime *datetime);
169 void g_date_time_get_dmy (const GDateTime *datetime,
170 gint *day,
171 gint *month,
172 gint *year);
174 GTimeSpan g_date_time_get_utc_offset (const GDateTime *datetime);
175 G_CONST_RETURN gchar *g_date_time_get_timezone_name (const GDateTime *datetime);
177 gboolean g_date_time_is_leap_year (const GDateTime *datetime);
178 gboolean g_date_time_is_daylight_savings (const GDateTime *datetime);
180 GDateTime * g_date_time_to_local (const GDateTime *datetime);
181 gint64 g_date_time_to_epoch (const GDateTime *datetime);
182 void g_date_time_to_timeval (const GDateTime *datetime,
183 GTimeVal *tv);
184 GDateTime * g_date_time_to_utc (const GDateTime *datetime);
185 gchar * g_date_time_printf (const GDateTime *datetime,
186 const gchar *format) G_GNUC_MALLOC;
188 G_END_DECLS
190 #endif /* __G_DATE_TIME_H__ */