You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

218 lines
11 KiB

  1. /*
  2. * Copyright (C) 2009-2010 Christian Hergert <chris@dronelabs.com>
  3. * Copyright © 2010 Codethink Limited
  4. *
  5. * This library is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as
  7. * published by the Free Software Foundation; either version 2.1 of the
  8. * licence, or (at your option) any later version.
  9. *
  10. * This is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  13. * License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
  18. * USA.
  19. *
  20. * Authors: Christian Hergert <chris@dronelabs.com>
  21. * Thiago Santos <thiago.sousa.santos@collabora.co.uk>
  22. * Emmanuele Bassi <ebassi@linux.intel.com>
  23. * Ryan Lortie <desrt@desrt.ca>
  24. */
  25. #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  26. #error "Only <glib.h> can be included directly."
  27. #endif
  28. #ifndef __G_DATE_TIME_H__
  29. #define __G_DATE_TIME_H__
  30. #include <glib/gtimezone.h>
  31. G_BEGIN_DECLS
  32. /**
  33. * G_TIME_SPAN_DAY:
  34. *
  35. * Evaluates to a time span of one day.
  36. *
  37. * Since: 2.26
  38. */
  39. #define G_TIME_SPAN_DAY (G_GINT64_CONSTANT (86400000000))
  40. /**
  41. * G_TIME_SPAN_HOUR:
  42. *
  43. * Evaluates to a time span of one hour.
  44. *
  45. * Since: 2.26
  46. */
  47. #define G_TIME_SPAN_HOUR (G_GINT64_CONSTANT (3600000000))
  48. /**
  49. * G_TIME_SPAN_MINUTE:
  50. *
  51. * Evaluates to a time span of one minute.
  52. *
  53. * Since: 2.26
  54. */
  55. #define G_TIME_SPAN_MINUTE (G_GINT64_CONSTANT (60000000))
  56. /**
  57. * G_TIME_SPAN_SECOND:
  58. *
  59. * Evaluates to a time span of one second.
  60. *
  61. * Since: 2.26
  62. */
  63. #define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT (1000000))
  64. /**
  65. * G_TIME_SPAN_MILLISECOND:
  66. *
  67. * Evaluates to a time span of one millisecond.
  68. *
  69. * Since: 2.26
  70. */
  71. #define G_TIME_SPAN_MILLISECOND (G_GINT64_CONSTANT (1000))
  72. /**
  73. * GTimeSpan:
  74. *
  75. * A value representing an interval of time, in microseconds.
  76. *
  77. * Since: 2.26
  78. */
  79. typedef gint64 GTimeSpan;
  80. /**
  81. * GDateTime:
  82. *
  83. * <structname>GDateTime</structname> is an opaque structure whose members
  84. * cannot be accessed directly.
  85. *
  86. * Since: 2.26
  87. */
  88. typedef struct _GDateTime GDateTime;
  89. void g_date_time_unref (GDateTime *datetime);
  90. GDateTime * g_date_time_ref (GDateTime *datetime);
  91. GDateTime * g_date_time_new_now (GTimeZone *tz);
  92. GDateTime * g_date_time_new_now_local (void);
  93. GDateTime * g_date_time_new_now_utc (void);
  94. GDateTime * g_date_time_new_from_unix_local (gint64 t);
  95. GDateTime * g_date_time_new_from_unix_utc (gint64 t);
  96. GDateTime * g_date_time_new_from_timeval_local (const GTimeVal *tv);
  97. GDateTime * g_date_time_new_from_timeval_utc (const GTimeVal *tv);
  98. GDateTime * g_date_time_new (GTimeZone *tz,
  99. gint year,
  100. gint month,
  101. gint day,
  102. gint hour,
  103. gint minute,
  104. gdouble seconds);
  105. GDateTime * g_date_time_new_local (gint year,
  106. gint month,
  107. gint day,
  108. gint hour,
  109. gint minute,
  110. gdouble seconds);
  111. GDateTime * g_date_time_new_utc (gint year,
  112. gint month,
  113. gint day,
  114. gint hour,
  115. gint minute,
  116. gdouble seconds);
  117. G_GNUC_WARN_UNUSED_RESULT
  118. GDateTime * g_date_time_add (GDateTime *datetime,
  119. GTimeSpan timespan);
  120. G_GNUC_WARN_UNUSED_RESULT
  121. GDateTime * g_date_time_add_years (GDateTime *datetime,
  122. gint years);
  123. G_GNUC_WARN_UNUSED_RESULT
  124. GDateTime * g_date_time_add_months (GDateTime *datetime,
  125. gint months);
  126. G_GNUC_WARN_UNUSED_RESULT
  127. GDateTime * g_date_time_add_weeks (GDateTime *datetime,
  128. gint weeks);
  129. G_GNUC_WARN_UNUSED_RESULT
  130. GDateTime * g_date_time_add_days (GDateTime *datetime,
  131. gint days);
  132. G_GNUC_WARN_UNUSED_RESULT
  133. GDateTime * g_date_time_add_hours (GDateTime *datetime,
  134. gint hours);
  135. G_GNUC_WARN_UNUSED_RESULT
  136. GDateTime * g_date_time_add_minutes (GDateTime *datetime,
  137. gint minutes);
  138. G_GNUC_WARN_UNUSED_RESULT
  139. GDateTime * g_date_time_add_seconds (GDateTime *datetime,
  140. gdouble seconds);
  141. G_GNUC_WARN_UNUSED_RESULT
  142. GDateTime * g_date_time_add_full (GDateTime *datetime,
  143. gint years,
  144. gint months,
  145. gint days,
  146. gint hours,
  147. gint minutes,
  148. gdouble seconds);
  149. gint g_date_time_compare (gconstpointer dt1,
  150. gconstpointer dt2);
  151. GTimeSpan g_date_time_difference (GDateTime *end,
  152. GDateTime *begin);
  153. guint g_date_time_hash (gconstpointer datetime);
  154. gboolean g_date_time_equal (gconstpointer dt1,
  155. gconstpointer dt2);
  156. void g_date_time_get_ymd (GDateTime *datetime,
  157. gint *year,
  158. gint *month,
  159. gint *day);
  160. gint g_date_time_get_year (GDateTime *datetime);
  161. gint g_date_time_get_month (GDateTime *datetime);
  162. gint g_date_time_get_day_of_month (GDateTime *datetime);
  163. gint g_date_time_get_week_numbering_year (GDateTime *datetime);
  164. gint g_date_time_get_week_of_year (GDateTime *datetime);
  165. gint g_date_time_get_day_of_week (GDateTime *datetime);
  166. gint g_date_time_get_day_of_year (GDateTime *datetime);
  167. gint g_date_time_get_hour (GDateTime *datetime);
  168. gint g_date_time_get_minute (GDateTime *datetime);
  169. gint g_date_time_get_second (GDateTime *datetime);
  170. gint g_date_time_get_microsecond (GDateTime *datetime);
  171. gdouble g_date_time_get_seconds (GDateTime *datetime);
  172. gint64 g_date_time_to_unix (GDateTime *datetime);
  173. gboolean g_date_time_to_timeval (GDateTime *datetime,
  174. GTimeVal *tv);
  175. GTimeSpan g_date_time_get_utc_offset (GDateTime *datetime);
  176. const gchar * g_date_time_get_timezone_abbreviation (GDateTime *datetime);
  177. gboolean g_date_time_is_daylight_savings (GDateTime *datetime);
  178. GDateTime * g_date_time_to_timezone (GDateTime *datetime,
  179. GTimeZone *tz);
  180. GDateTime * g_date_time_to_local (GDateTime *datetime);
  181. GDateTime * g_date_time_to_utc (GDateTime *datetime);
  182. gchar * g_date_time_format (GDateTime *datetime,
  183. const gchar *format) G_GNUC_MALLOC;
  184. G_END_DECLS
  185. #endif /* __G_DATE_TIME_H__ */