gstdatetime.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. #ifndef __GST_DATE_TIME_H__
  20. #define __GST_DATE_TIME_H__
  21. #include <gst/gstconfig.h>
  22. #include <time.h>
  23. #include <glib.h>
  24. #include <glib-object.h>
  25. G_BEGIN_DECLS
  26. /**
  27. * GstDateTime:
  28. *
  29. * Opaque, immutable, refcounted struct that stores date, time and timezone
  30. * information. It currently supports ranges from 0001-01-01 to
  31. * 9999-12-31 in the Gregorian proleptic calendar.
  32. *
  33. * Use the accessor functions to get the stored values.
  34. */
  35. typedef struct _GstDateTime GstDateTime;
  36. GST_EXPORT GType _gst_date_time_type;
  37. /**
  38. * GST_TYPE_DATE_TIME:
  39. *
  40. * a boxed #GValue type for #GstDateTime that represents a date and time.
  41. *
  42. * Returns: the #GType of GstDateTime
  43. */
  44. #define GST_TYPE_DATE_TIME (_gst_date_time_type)
  45. GType gst_date_time_get_type (void);
  46. /* query which fields are set */
  47. gboolean gst_date_time_has_year (const GstDateTime * datetime);
  48. gboolean gst_date_time_has_month (const GstDateTime * datetime);
  49. gboolean gst_date_time_has_day (const GstDateTime * datetime);
  50. gboolean gst_date_time_has_time (const GstDateTime * datetime);
  51. gboolean gst_date_time_has_second (const GstDateTime * datetime);
  52. /* field getters */
  53. gint gst_date_time_get_year (const GstDateTime * datetime);
  54. gint gst_date_time_get_month (const GstDateTime * datetime);
  55. gint gst_date_time_get_day (const GstDateTime * datetime);
  56. gint gst_date_time_get_hour (const GstDateTime * datetime);
  57. gint gst_date_time_get_minute (const GstDateTime * datetime);
  58. gint gst_date_time_get_second (const GstDateTime * datetime);
  59. gint gst_date_time_get_microsecond (const GstDateTime * datetime);
  60. gfloat gst_date_time_get_time_zone_offset (const GstDateTime * datetime);
  61. /* constructors */
  62. GstDateTime * gst_date_time_new_from_unix_epoch_local_time (gint64 secs) G_GNUC_MALLOC;
  63. GstDateTime * gst_date_time_new_from_unix_epoch_utc (gint64 secs) G_GNUC_MALLOC;
  64. GstDateTime * gst_date_time_new_local_time (gint year,
  65. gint month,
  66. gint day,
  67. gint hour,
  68. gint minute,
  69. gdouble seconds) G_GNUC_MALLOC;
  70. GstDateTime * gst_date_time_new_y (gint year) G_GNUC_MALLOC;
  71. GstDateTime * gst_date_time_new_ym (gint year,
  72. gint month) G_GNUC_MALLOC;
  73. GstDateTime * gst_date_time_new_ymd (gint year,
  74. gint month,
  75. gint day) G_GNUC_MALLOC;
  76. GstDateTime * gst_date_time_new (gfloat tzoffset,
  77. gint year, gint month,
  78. gint day, gint hour,
  79. gint minute,
  80. gdouble seconds) G_GNUC_MALLOC;
  81. GstDateTime * gst_date_time_new_now_local_time (void) G_GNUC_MALLOC;
  82. GstDateTime * gst_date_time_new_now_utc (void) G_GNUC_MALLOC;
  83. gchar * gst_date_time_to_iso8601_string (GstDateTime * datetime) G_GNUC_MALLOC;
  84. GstDateTime * gst_date_time_new_from_iso8601_string (const gchar * string) G_GNUC_MALLOC;
  85. GDateTime * gst_date_time_to_g_date_time (GstDateTime * datetime);
  86. GstDateTime * gst_date_time_new_from_g_date_time (GDateTime * dt);
  87. /* refcounting */
  88. GstDateTime * gst_date_time_ref (GstDateTime * datetime);
  89. void gst_date_time_unref (GstDateTime * datetime);
  90. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  91. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDateTime, gst_date_time_unref)
  92. #endif
  93. G_END_DECLS
  94. #endif /* __GST_DATE_TIME_H__ */