| 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 |  | 
| 29 | G_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 |  */ | 
| 40 | typedef struct _GstDateTime GstDateTime; | 
| 41 |  | 
| 42 | GST_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 |  | 
| 54 | GST_API | 
| 55 | GType           gst_date_time_get_type (void); | 
| 56 |  | 
| 57 | /* query which fields are set */ | 
| 58 |  | 
| 59 | GST_API | 
| 60 | gboolean        gst_date_time_has_year                (const GstDateTime * datetime); | 
| 61 |  | 
| 62 | GST_API | 
| 63 | gboolean        gst_date_time_has_month               (const GstDateTime * datetime); | 
| 64 |  | 
| 65 | GST_API | 
| 66 | gboolean        gst_date_time_has_day                 (const GstDateTime * datetime); | 
| 67 |  | 
| 68 | GST_API | 
| 69 | gboolean        gst_date_time_has_time                (const GstDateTime * datetime); | 
| 70 |  | 
| 71 | GST_API | 
| 72 | gboolean        gst_date_time_has_second              (const GstDateTime * datetime); | 
| 73 |  | 
| 74 | /* field getters */ | 
| 75 |  | 
| 76 | GST_API | 
| 77 | gint            gst_date_time_get_year                (const GstDateTime * datetime); | 
| 78 |  | 
| 79 | GST_API | 
| 80 | gint            gst_date_time_get_month               (const GstDateTime * datetime); | 
| 81 |  | 
| 82 | GST_API | 
| 83 | gint            gst_date_time_get_day                 (const GstDateTime * datetime); | 
| 84 |  | 
| 85 | GST_API | 
| 86 | gint            gst_date_time_get_hour                (const GstDateTime * datetime); | 
| 87 |  | 
| 88 | GST_API | 
| 89 | gint            gst_date_time_get_minute              (const GstDateTime * datetime); | 
| 90 |  | 
| 91 | GST_API | 
| 92 | gint            gst_date_time_get_second              (const GstDateTime * datetime); | 
| 93 |  | 
| 94 | GST_API | 
| 95 | gint            gst_date_time_get_microsecond         (const GstDateTime * datetime); | 
| 96 |  | 
| 97 | GST_API | 
| 98 | gfloat          gst_date_time_get_time_zone_offset    (const GstDateTime * datetime); | 
| 99 |  | 
| 100 | /* constructors */ | 
| 101 |  | 
| 102 | GST_API | 
| 103 | GstDateTime *   gst_date_time_new_from_unix_epoch_local_time (gint64 secs) G_GNUC_MALLOC; | 
| 104 |  | 
| 105 | GST_API | 
| 106 | GstDateTime *   gst_date_time_new_from_unix_epoch_utc   (gint64 secs) G_GNUC_MALLOC; | 
| 107 |  | 
| 108 | GST_API | 
| 109 | GstDateTime *   gst_date_time_new_from_unix_epoch_local_time_usecs (gint64 usecs) G_GNUC_MALLOC; | 
| 110 |  | 
| 111 | GST_API | 
| 112 | GstDateTime *   gst_date_time_new_from_unix_epoch_utc_usecs (gint64 usecs) G_GNUC_MALLOC; | 
| 113 |  | 
| 114 | GST_API | 
| 115 | GstDateTime *   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; | 
| 121 | GST_API | 
| 122 | GstDateTime *   gst_date_time_new_y                     (gint year) G_GNUC_MALLOC; | 
| 123 |  | 
| 124 | GST_API | 
| 125 | GstDateTime *   gst_date_time_new_ym                    (gint year, | 
| 126 |                                                          gint month) G_GNUC_MALLOC; | 
| 127 | GST_API | 
| 128 | GstDateTime *   gst_date_time_new_ymd                   (gint year, | 
| 129 |                                                          gint month, | 
| 130 |                                                          gint day) G_GNUC_MALLOC; | 
| 131 | GST_API | 
| 132 | GstDateTime *   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; | 
| 137 | GST_API | 
| 138 | GstDateTime *   gst_date_time_new_now_local_time (void) G_GNUC_MALLOC; | 
| 139 |  | 
| 140 | GST_API | 
| 141 | GstDateTime *   gst_date_time_new_now_utc        (void) G_GNUC_MALLOC; | 
| 142 |  | 
| 143 | GST_API | 
| 144 | gchar *         gst_date_time_to_iso8601_string  (GstDateTime * datetime) G_GNUC_MALLOC; | 
| 145 |  | 
| 146 | GST_API | 
| 147 | GstDateTime *   gst_date_time_new_from_iso8601_string  (const gchar * string) G_GNUC_MALLOC; | 
| 148 |  | 
| 149 | GST_API | 
| 150 | GDateTime *     gst_date_time_to_g_date_time       (GstDateTime * datetime); | 
| 151 |  | 
| 152 | GST_API | 
| 153 | GstDateTime *   gst_date_time_new_from_g_date_time (GDateTime * dt); | 
| 154 |  | 
| 155 | /* refcounting */ | 
| 156 |  | 
| 157 | GST_API | 
| 158 | GstDateTime *   gst_date_time_ref                (GstDateTime * datetime); | 
| 159 |  | 
| 160 | GST_API | 
| 161 | void            gst_date_time_unref              (GstDateTime * datetime); | 
| 162 |  | 
| 163 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDateTime, gst_date_time_unref) | 
| 164 |  | 
| 165 | G_END_DECLS | 
| 166 |  | 
| 167 | #endif /* __GST_DATE_TIME_H__ */ | 
| 168 |  |