summaryrefslogtreecommitdiff
path: root/include/gst/gstdatetime.h
blob: 8d2b74770d805c9c36bdac26bf936faad784c6b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* GStreamer
 * Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef __GST_DATE_TIME_H__
#define __GST_DATE_TIME_H__

#include <gst/gstconfig.h>

#include <time.h>
#include <glib.h>
#include <glib-object.h>

G_BEGIN_DECLS

/**
 * GstDateTime:
 *
 * Opaque, immutable, refcounted struct that stores date, time and timezone
 * information. It currently supports ranges from `0001-01-01` to
 * `9999-12-31` in the Gregorian proleptic calendar.
 *
 * Use the accessor functions to get the stored values.
 */
typedef struct _GstDateTime GstDateTime;

GST_API GType _gst_date_time_type;

/**
 * GST_TYPE_DATE_TIME:
 *
 * a boxed #GValue type for #GstDateTime that represents a date and time.
 *
 * Returns: the #GType of GstDateTime
 */

#define GST_TYPE_DATE_TIME (_gst_date_time_type)

GST_API
GType           gst_date_time_get_type (void);

/* query which fields are set */

GST_API
gboolean        gst_date_time_has_year                (const GstDateTime * datetime);

GST_API
gboolean        gst_date_time_has_month               (const GstDateTime * datetime);

GST_API
gboolean        gst_date_time_has_day                 (const GstDateTime * datetime);

GST_API
gboolean        gst_date_time_has_time                (const GstDateTime * datetime);

GST_API
gboolean        gst_date_time_has_second              (const GstDateTime * datetime);

/* field getters */

GST_API
gint            gst_date_time_get_year                (const GstDateTime * datetime);

GST_API
gint            gst_date_time_get_month               (const GstDateTime * datetime);

GST_API
gint            gst_date_time_get_day                 (const GstDateTime * datetime);

GST_API
gint            gst_date_time_get_hour                (const GstDateTime * datetime);

GST_API
gint            gst_date_time_get_minute              (const GstDateTime * datetime);

GST_API
gint            gst_date_time_get_second              (const GstDateTime * datetime);

GST_API
gint            gst_date_time_get_microsecond         (const GstDateTime * datetime);

GST_API
gfloat          gst_date_time_get_time_zone_offset    (const GstDateTime * datetime);

/* constructors */

GST_API
GstDateTime *   gst_date_time_new_from_unix_epoch_local_time (gint64 secs) G_GNUC_MALLOC;

GST_API
GstDateTime *   gst_date_time_new_from_unix_epoch_utc   (gint64 secs) G_GNUC_MALLOC;

GST_API
GstDateTime *   gst_date_time_new_from_unix_epoch_local_time_usecs (gint64 usecs) G_GNUC_MALLOC;

GST_API
GstDateTime *   gst_date_time_new_from_unix_epoch_utc_usecs (gint64 usecs) G_GNUC_MALLOC;

GST_API
GstDateTime *   gst_date_time_new_local_time            (gint year,
                                                         gint month,
                                                         gint day,
                                                         gint hour,
                                                         gint minute,
                                                         gdouble seconds) G_GNUC_MALLOC;
GST_API
GstDateTime *   gst_date_time_new_y                     (gint year) G_GNUC_MALLOC;

GST_API
GstDateTime *   gst_date_time_new_ym                    (gint year,
                                                         gint month) G_GNUC_MALLOC;
GST_API
GstDateTime *   gst_date_time_new_ymd                   (gint year,
                                                         gint month,
                                                         gint day) G_GNUC_MALLOC;
GST_API
GstDateTime *   gst_date_time_new                       (gfloat tzoffset,
                                                         gint year, gint month,
                                                         gint day, gint hour,
                                                         gint minute,
                                                         gdouble seconds) G_GNUC_MALLOC;
GST_API
GstDateTime *   gst_date_time_new_now_local_time (void) G_GNUC_MALLOC;

GST_API
GstDateTime *   gst_date_time_new_now_utc        (void) G_GNUC_MALLOC;

GST_API
gchar *         gst_date_time_to_iso8601_string  (GstDateTime * datetime) G_GNUC_MALLOC;

GST_API
GstDateTime *   gst_date_time_new_from_iso8601_string  (const gchar * string) G_GNUC_MALLOC;

GST_API
GDateTime *     gst_date_time_to_g_date_time       (GstDateTime * datetime);

GST_API
GstDateTime *   gst_date_time_new_from_g_date_time (GDateTime * dt);

/* refcounting */

GST_API
GstDateTime *   gst_date_time_ref                (GstDateTime * datetime);

GST_API
void            gst_date_time_unref              (GstDateTime * datetime);

G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDateTime, gst_date_time_unref)

G_END_DECLS

#endif /* __GST_DATE_TIME_H__ */