1/* GStreamer
2 * Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
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_from_unix_epoch_local_time_usecs (gint64 usecs) G_GNUC_MALLOC;
110
111GST_API
112GstDateTime * gst_date_time_new_from_unix_epoch_utc_usecs (gint64 usecs) G_GNUC_MALLOC;
113
114GST_API
115GstDateTime * gst_date_time_new_local_time (gint year,
116 gint month,
117 gint day,
118 gint hour,
119 gint minute,
120 gdouble seconds) G_GNUC_MALLOC;
121GST_API
122GstDateTime * gst_date_time_new_y (gint year) G_GNUC_MALLOC;
123
124GST_API
125GstDateTime * gst_date_time_new_ym (gint year,
126 gint month) G_GNUC_MALLOC;
127GST_API
128GstDateTime * gst_date_time_new_ymd (gint year,
129 gint month,
130 gint day) G_GNUC_MALLOC;
131GST_API
132GstDateTime * gst_date_time_new (gfloat tzoffset,
133 gint year, gint month,
134 gint day, gint hour,
135 gint minute,
136 gdouble seconds) G_GNUC_MALLOC;
137GST_API
138GstDateTime * gst_date_time_new_now_local_time (void) G_GNUC_MALLOC;
139
140GST_API
141GstDateTime * gst_date_time_new_now_utc (void) G_GNUC_MALLOC;
142
143GST_API
144gchar * gst_date_time_to_iso8601_string (GstDateTime * datetime) G_GNUC_MALLOC;
145
146GST_API
147GstDateTime * gst_date_time_new_from_iso8601_string (const gchar * string) G_GNUC_MALLOC;
148
149GST_API
150GDateTime * gst_date_time_to_g_date_time (GstDateTime * datetime);
151
152GST_API
153GstDateTime * gst_date_time_new_from_g_date_time (GDateTime * dt);
154
155/* refcounting */
156
157GST_API
158GstDateTime * gst_date_time_ref (GstDateTime * datetime);
159
160GST_API
161void gst_date_time_unref (GstDateTime * datetime);
162
163G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDateTime, gst_date_time_unref)
164
165G_END_DECLS
166
167#endif /* __GST_DATE_TIME_H__ */
168

source code of include/gstreamer-1.0/gst/gstdatetime.h