2010-07-16 17:09:12 +00:00
|
|
|
/* 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
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-07-16 17:09:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_DATE_TIME_H__
|
|
|
|
#define __GST_DATE_TIME_H__
|
|
|
|
|
2014-09-22 17:05:32 +00:00
|
|
|
#include <gst/gstconfig.h>
|
|
|
|
|
2010-07-16 17:09:12 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <glib.h>
|
2014-09-22 17:05:32 +00:00
|
|
|
#include <glib-object.h>
|
2010-07-16 17:09:12 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstDateTime:
|
|
|
|
*
|
2010-09-27 22:35:08 +00:00
|
|
|
* Opaque, immutable, refcounted struct that stores date, time and timezone
|
2010-07-16 17:09:12 +00:00
|
|
|
* information. It currently supports ranges from 0001-01-01 to
|
|
|
|
* 9999-12-31 in the Gregorian proleptic calendar.
|
|
|
|
*
|
2013-12-07 14:38:19 +00:00
|
|
|
* Use the accessor functions to get the stored values.
|
2010-07-16 17:09:12 +00:00
|
|
|
*/
|
|
|
|
typedef struct _GstDateTime GstDateTime;
|
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API GType _gst_date_time_type;
|
2014-06-19 06:05:03 +00:00
|
|
|
|
2014-06-03 22:38:28 +00:00
|
|
|
/**
|
|
|
|
* GST_TYPE_DATE_TIME:
|
|
|
|
*
|
|
|
|
* a boxed #GValue type for #GstDateTime that represents a date and time.
|
|
|
|
*
|
|
|
|
* Returns: the #GType of GstDateTime
|
|
|
|
*/
|
|
|
|
|
2014-06-19 06:05:03 +00:00
|
|
|
#define GST_TYPE_DATE_TIME (_gst_date_time_type)
|
2014-06-03 22:38:28 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2014-06-03 22:38:28 +00:00
|
|
|
GType gst_date_time_get_type (void);
|
|
|
|
|
2012-06-12 22:52:02 +00:00
|
|
|
/* query which fields are set */
|
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gboolean gst_date_time_has_year (const GstDateTime * datetime);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gboolean gst_date_time_has_month (const GstDateTime * datetime);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gboolean gst_date_time_has_day (const GstDateTime * datetime);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gboolean gst_date_time_has_time (const GstDateTime * datetime);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gboolean gst_date_time_has_second (const GstDateTime * datetime);
|
|
|
|
|
|
|
|
/* field getters */
|
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gint gst_date_time_get_year (const GstDateTime * datetime);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gint gst_date_time_get_month (const GstDateTime * datetime);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gint gst_date_time_get_day (const GstDateTime * datetime);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gint gst_date_time_get_hour (const GstDateTime * datetime);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gint gst_date_time_get_minute (const GstDateTime * datetime);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gint gst_date_time_get_second (const GstDateTime * datetime);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gint gst_date_time_get_microsecond (const GstDateTime * datetime);
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
gfloat gst_date_time_get_time_zone_offset (const GstDateTime * datetime);
|
|
|
|
|
|
|
|
/* constructors */
|
2010-07-16 17:09:12 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-11-26 19:44:23 +00:00
|
|
|
GstDateTime * gst_date_time_new_from_unix_epoch_local_time (gint64 secs) G_GNUC_MALLOC;
|
2012-06-12 22:52:02 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-11-26 19:44:23 +00:00
|
|
|
GstDateTime * gst_date_time_new_from_unix_epoch_utc (gint64 secs) G_GNUC_MALLOC;
|
2012-06-12 22:52:02 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
GstDateTime * gst_date_time_new_local_time (gint year,
|
|
|
|
gint month,
|
|
|
|
gint day,
|
|
|
|
gint hour,
|
2011-11-11 15:52:41 +00:00
|
|
|
gint minute,
|
2011-11-26 19:44:23 +00:00
|
|
|
gdouble seconds) G_GNUC_MALLOC;
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 20:35:42 +00:00
|
|
|
GstDateTime * gst_date_time_new_y (gint year) G_GNUC_MALLOC;
|
2012-06-12 22:52:02 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
GstDateTime * gst_date_time_new_ym (gint year,
|
|
|
|
gint month) G_GNUC_MALLOC;
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-12 22:52:02 +00:00
|
|
|
GstDateTime * gst_date_time_new_ymd (gint year,
|
|
|
|
gint month,
|
2012-06-12 20:35:42 +00:00
|
|
|
gint day) G_GNUC_MALLOC;
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-11-11 15:52:41 +00:00
|
|
|
GstDateTime * gst_date_time_new (gfloat tzoffset,
|
|
|
|
gint year, gint month,
|
|
|
|
gint day, gint hour,
|
|
|
|
gint minute,
|
2011-11-26 19:44:23 +00:00
|
|
|
gdouble seconds) G_GNUC_MALLOC;
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-11-26 19:44:23 +00:00
|
|
|
GstDateTime * gst_date_time_new_now_local_time (void) G_GNUC_MALLOC;
|
2012-06-12 22:52:02 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-11-26 19:44:23 +00:00
|
|
|
GstDateTime * gst_date_time_new_now_utc (void) G_GNUC_MALLOC;
|
2010-07-16 17:09:12 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-18 06:06:49 +00:00
|
|
|
gchar * gst_date_time_to_iso8601_string (GstDateTime * datetime) G_GNUC_MALLOC;
|
2017-05-10 09:56:16 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-18 06:06:49 +00:00
|
|
|
GstDateTime * gst_date_time_new_from_iso8601_string (const gchar * string) G_GNUC_MALLOC;
|
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-30 01:52:47 +00:00
|
|
|
GDateTime * gst_date_time_to_g_date_time (GstDateTime * datetime);
|
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2012-06-30 01:52:47 +00:00
|
|
|
GstDateTime * gst_date_time_new_from_g_date_time (GDateTime * dt);
|
|
|
|
|
2012-06-12 22:52:02 +00:00
|
|
|
/* refcounting */
|
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-11-11 15:52:41 +00:00
|
|
|
GstDateTime * gst_date_time_ref (GstDateTime * datetime);
|
2012-06-12 22:52:02 +00:00
|
|
|
|
2018-03-12 23:03:26 +00:00
|
|
|
GST_API
|
2011-11-11 15:52:41 +00:00
|
|
|
void gst_date_time_unref (GstDateTime * datetime);
|
2010-07-16 17:09:12 +00:00
|
|
|
|
2015-11-10 17:38:59 +00:00
|
|
|
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDateTime, gst_date_time_unref)
|
|
|
|
#endif
|
|
|
|
|
2010-07-16 17:09:12 +00:00
|
|
|
G_END_DECLS
|
2012-06-12 22:52:02 +00:00
|
|
|
|
2010-07-16 17:09:12 +00:00
|
|
|
#endif /* __GST_DATE_TIME_H__ */
|