1/* GStreamer
2 * Copyright (C) 2010 Thiago Santos <[email protected]>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef __GST_DATE_TIME_H__
21#define __GST_DATE_TIME_H__
22
23#include <gst/gstconfig.h>
24
25#include <time.h>
26#include <glib.h>
27#include <glib-object.h>
28
29G_BEGIN_DECLS
30
31/**
32 * GstDateTime:
33 *
34 * Opaque, immutable, refcounted struct that stores date, time and timezone
35 * information. It currently supports ranges from 0001-01-01 to
36 * 9999-12-31 in the Gregorian proleptic calendar.
37 *
38 * Use the accessor functions to get the stored values.
39 */
40typedef struct _GstDateTime GstDateTime;
41
42GST_API GType _gst_date_time_type;
43
44/**
45 * GST_TYPE_DATE_TIME:
46 *
47 * a boxed #GValue type for #GstDateTime that represents a date and time.
48 *
49 * Returns: the #GType of GstDateTime
50 */
51
52#define GST_TYPE_DATE_TIME (_gst_date_time_type)
53
54GST_API
55GType gst_date_time_get_type (void);
56
57/* query which fields are set */
58
59GST_API
60gboolean gst_date_time_has_year (const GstDateTime * datetime);
61
62GST_API
63gboolean gst_date_time_has_month (const GstDateTime * datetime);
64
65GST_API
66gboolean gst_date_time_has_day (const GstDateTime * datetime);
67
68GST_API
69gboolean gst_date_time_has_time (const GstDateTime * datetime);
70
71GST_API
72gboolean gst_date_time_has_second (const GstDateTime * datetime);
73
74/* field getters */
75
76GST_API
77gint gst_date_time_get_year (const GstDateTime * datetime);
78
79GST_API
80gint gst_date_time_get_month (const GstDateTime * datetime);
81
82GST_API
83gint gst_date_time_get_day (const GstDateTime * datetime);
84
85GST_API
86gint gst_date_time_get_hour (const GstDateTime * datetime);
87
88GST_API
89gint gst_date_time_get_minute (const GstDateTime * datetime);
90
91GST_API
92gint gst_date_time_get_second (const GstDateTime * datetime);
93
94GST_API
95gint gst_date_time_get_microsecond (const GstDateTime * datetime);
96
97GST_API
98gfloat gst_date_time_get_time_zone_offset (const GstDateTime * datetime);
99
100/* constructors */
101
102GST_API
103GstDateTime * gst_date_time_new_from_unix_epoch_local_time (gint64 secs) G_GNUC_MALLOC;
104
105GST_API
106GstDateTime * gst_date_time_new_from_unix_epoch_utc (gint64 secs) G_GNUC_MALLOC;
107
108GST_API
109GstDateTime * gst_date_time_new_local_time (gint year,
110 gint month,
111 gint day,
112 gint hour,
113 gint minute,
114 gdouble seconds) G_GNUC_MALLOC;
115GST_API
116GstDateTime * gst_date_time_new_y (gint year) G_GNUC_MALLOC;
117
118GST_API
119GstDateTime * gst_date_time_new_ym (gint year,
120 gint month) G_GNUC_MALLOC;
121GST_API
122GstDateTime * gst_date_time_new_ymd (gint year,
123 gint month,
124 gint day) G_GNUC_MALLOC;
125GST_API
126GstDateTime * gst_date_time_new (gfloat tzoffset,
127 gint year, gint month,
128 gint day, gint hour,
129 gint minute,
130 gdouble seconds) G_GNUC_MALLOC;
131GST_API
132GstDateTime * gst_date_time_new_now_local_time (void) G_GNUC_MALLOC;
133
134GST_API
135GstDateTime * gst_date_time_new_now_utc (void) G_GNUC_MALLOC;
136
137GST_API
138gchar * gst_date_time_to_iso8601_string (GstDateTime * datetime) G_GNUC_MALLOC;
139
140GST_API
141GstDateTime * gst_date_time_new_from_iso8601_string (const gchar * string) G_GNUC_MALLOC;
142
143GST_API
144GDateTime * gst_date_time_to_g_date_time (GstDateTime * datetime);
145
146GST_API
147GstDateTime * gst_date_time_new_from_g_date_time (GDateTime * dt);
148
149/* refcounting */
150
151GST_API
152GstDateTime * gst_date_time_ref (GstDateTime * datetime);
153
154GST_API
155void gst_date_time_unref (GstDateTime * datetime);
156
157#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
158G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDateTime, gst_date_time_unref)
159#endif
160
161G_END_DECLS
162
163#endif /* __GST_DATE_TIME_H__ */
164