/src/wrappers/glib/library/utilities/glib_date_and_time_functions.e

http://github.com/tybor/Liberty · Specman e · 1101 lines · 2 code · 361 blank · 738 comment · 0 complexity · 594646f10ed99ae698a3b53d546da5f9 MD5 · raw file

  1. deferred class GLIB_DATE_AND_TIME_FUNCTIONS
  2. -- Top | Description
  3. -- Date and Time Functions
  4. -- Date and Time Functions -- calendrical calculations and miscellaneous time
  5. -- stuff.
  6. -- Synopsis
  7. -- #include <glib.h>
  8. -- #define G_USEC_PER_SEC
  9. -- GTimeVal;
  10. -- void g_get_current_time (GTimeVal *result);
  11. -- void g_usleep (gulong microseconds);
  12. -- void g_time_val_add (GTimeVal *time_,
  13. -- glong microseconds);
  14. -- gboolean g_time_val_from_iso8601 (const gchar *iso_date,
  15. -- GTimeVal *time_);
  16. -- gchar* g_time_val_to_iso8601 (GTimeVal *time_);
  17. -- GDate;
  18. -- typedef GTime;
  19. -- enum GDateDMY;
  20. -- typedef GDateDay;
  21. -- enum GDateMonth;
  22. -- typedef GDateYear;
  23. -- enum GDateWeekday;
  24. -- #define G_DATE_BAD_DAY
  25. -- #define G_DATE_BAD_JULIAN
  26. -- #define G_DATE_BAD_YEAR
  27. -- GDate* g_date_new (void);
  28. -- GDate* g_date_new_dmy (GDateDay day,
  29. -- GDateMonth month,
  30. -- GDateYear year);
  31. -- GDate* g_date_new_julian (guint32 julian_day);
  32. -- void g_date_clear (GDate *date,
  33. -- guint n_dates);
  34. -- void g_date_free (GDate *date);
  35. -- void g_date_set_day (GDate *date,
  36. -- GDateDay day);
  37. -- void g_date_set_month (GDate *date,
  38. -- GDateMonth month);
  39. -- void g_date_set_year (GDate *date,
  40. -- GDateYear year);
  41. -- void g_date_set_dmy (GDate *date,
  42. -- GDateDay day,
  43. -- GDateMonth month,
  44. -- GDateYear y);
  45. -- void g_date_set_julian (GDate *date,
  46. -- guint32 julian_date);
  47. -- void g_date_set_time (GDate *date,
  48. -- GTime time_);
  49. -- void g_date_set_time_t (GDate *date,
  50. -- time_t timet);
  51. -- void g_date_set_time_val (GDate *date,
  52. -- GTimeVal *timeval);
  53. -- void g_date_set_parse (GDate *date,
  54. -- const gchar *str);
  55. -- void g_date_add_days (GDate *date,
  56. -- guint n_days);
  57. -- void g_date_subtract_days (GDate *date,
  58. -- guint n_days);
  59. -- void g_date_add_months (GDate *date,
  60. -- guint n_months);
  61. -- void g_date_subtract_months (GDate *date,
  62. -- guint n_months);
  63. -- void g_date_add_years (GDate *date,
  64. -- guint n_years);
  65. -- void g_date_subtract_years (GDate *date,
  66. -- guint n_years);
  67. -- gint g_date_days_between (const GDate *date1,
  68. -- const GDate *date2);
  69. -- gint g_date_compare (const GDate *lhs,
  70. -- const GDate *rhs);
  71. -- void g_date_clamp (GDate *date,
  72. -- const GDate *min_date,
  73. -- const GDate *max_date);
  74. -- void g_date_order (GDate *date1,
  75. -- GDate *date2);
  76. -- GDateDay g_date_get_day (const GDate *date);
  77. -- GDateMonth g_date_get_month (const GDate *date);
  78. -- GDateYear g_date_get_year (const GDate *date);
  79. -- guint32 g_date_get_julian (const GDate *date);
  80. -- GDateWeekday g_date_get_weekday (const GDate *date);
  81. -- guint g_date_get_day_of_year (const GDate *date);
  82. -- guint8 g_date_get_days_in_month (GDateMonth month,
  83. -- GDateYear year);
  84. -- gboolean g_date_is_first_of_month (const GDate *date);
  85. -- gboolean g_date_is_last_of_month (const GDate *date);
  86. -- gboolean g_date_is_leap_year (GDateYear year);
  87. -- guint g_date_get_monday_week_of_year (const GDate *date);
  88. -- guint8 g_date_get_monday_weeks_in_year (GDateYear year);
  89. -- guint g_date_get_sunday_week_of_year (const GDate *date);
  90. -- guint8 g_date_get_sunday_weeks_in_year (GDateYear year);
  91. -- guint g_date_get_iso8601_week_of_year (const GDate *date);
  92. -- gsize g_date_strftime (gchar *s,
  93. -- gsize slen,
  94. -- const gchar *format,
  95. -- const GDate *date);
  96. -- void g_date_to_struct_tm (const GDate *date,
  97. -- struct tm *tm);
  98. -- gboolean g_date_valid (const GDate *date);
  99. -- gboolean g_date_valid_day (GDateDay day);
  100. -- gboolean g_date_valid_month (GDateMonth month);
  101. -- gboolean g_date_valid_year (GDateYear year);
  102. -- gboolean g_date_valid_dmy (GDateDay day,
  103. -- GDateMonth month,
  104. -- GDateYear year);
  105. -- gboolean g_date_valid_julian (guint32 julian_date);
  106. -- gboolean g_date_valid_weekday (GDateWeekday weekday);
  107. -- Description
  108. -- The GDate data structure represents a day between January 1, Year 1, and sometime
  109. -- a few thousand years in the future (right now it will go to the year 65535 or so,
  110. -- but g_date_set_parse() only parses up to the year 8000 or so - just count on "a
  111. -- few thousand"). GDate is meant to represent everyday dates, not astronomical
  112. -- dates or historical dates or ISO timestamps or the like. It extrapolates the
  113. -- current Gregorian calendar forward and backward in time; there is no attempt to
  114. -- change the calendar to match time periods or locations. GDate does not store time
  115. -- information; it represents a day.
  116. -- The GDate implementation has several nice features; it is only a 64-bit struct,
  117. -- so storing large numbers of dates is very efficient. It can keep both a Julian
  118. -- and day-month-year representation of the date, since some calculations are much
  119. -- easier with one representation or the other. A Julian representation is simply a
  120. -- count of days since some fixed day in the past; for GDate the fixed day is
  121. -- January 1, 1 AD. ("Julian" dates in the GDate API aren't really Julian dates in
  122. -- the technical sense; technically, Julian dates count from the start of the Julian
  123. -- period, Jan 1, 4713 BC).
  124. -- GDate is simple to use. First you need a "blank" date; you can get a dynamically
  125. -- allocated date from g_date_new(), or you can declare an automatic variable or
  126. -- array and initialize it to a sane state by calling g_date_clear(). A cleared date
  127. -- is sane; it's safe to call g_date_set_dmy() and the other mutator functions to
  128. -- initialize the value of a cleared date. However, a cleared date is initially
  129. -- invalid, meaning that it doesn't represent a day that exists. It is undefined to
  130. -- call any of the date calculation routines on an invalid date. If you obtain a
  131. -- date from a user or other unpredictable source, you should check its validity
  132. -- with the g_date_valid() predicate. g_date_valid() is also used to check for
  133. -- errors with g_date_set_parse() and other functions that can fail. Dates can be
  134. -- invalidated by calling g_date_clear() again.
  135. -- It is very important to use the API to access the GDate struct. Often only the
  136. -- day-month-year or only the Julian representation is valid. Sometimes neither is
  137. -- valid. Use the API.
  138. -- GLib doesn't contain any time-manipulation functions; however, there is a GTime
  139. -- typedef and a GTimeVal struct which represents a more precise time (with
  140. -- microseconds). You can request the current time as a GTimeVal with
  141. -- g_get_current_time().
  142. -- Details
  143. -- G_USEC_PER_SEC
  144. -- #define G_USEC_PER_SEC 1000000
  145. -- Number of microseconds in one second (1 million). This macro is provided for code
  146. -- readability.
  147. -- ---------------------------------------------------------------------------------
  148. -- GTimeVal
  149. -- typedef struct {
  150. -- glong tv_sec;
  151. -- glong tv_usec;
  152. -- } GTimeVal;
  153. -- Represents a precise time, with seconds and microseconds. Similar to the struct
  154. -- timeval returned by the gettimeofday() UNIX call.
  155. -- glong tv_sec; seconds.
  156. -- glong tv_usec; microseconds.
  157. -- ---------------------------------------------------------------------------------
  158. -- g_get_current_time ()
  159. -- void g_get_current_time (GTimeVal *result);
  160. -- Equivalent to the UNIX gettimeofday() function, but portable.
  161. -- result : GTimeVal structure in which to store current time.
  162. -- ---------------------------------------------------------------------------------
  163. -- g_usleep ()
  164. -- void g_usleep (gulong microseconds);
  165. -- Pauses the current thread for the given number of microseconds. There are 1
  166. -- million microseconds per second (represented by the G_USEC_PER_SEC macro).
  167. -- g_usleep() may have limited precision, depending on hardware and operating
  168. -- system; don't rely on the exact length of the sleep.
  169. -- microseconds : number of microseconds to pause.
  170. -- ---------------------------------------------------------------------------------
  171. -- g_time_val_add ()
  172. -- void g_time_val_add (GTimeVal *time_,
  173. -- glong microseconds);
  174. -- Adds the given number of microseconds to time_. microseconds can also be negative
  175. -- to decrease the value of time_.
  176. -- time_ : a GTimeVal
  177. -- microseconds : number of microseconds to add to time
  178. -- ---------------------------------------------------------------------------------
  179. -- g_time_val_from_iso8601 ()
  180. -- gboolean g_time_val_from_iso8601 (const gchar *iso_date,
  181. -- GTimeVal *time_);
  182. -- Converts a string containing an ISO 8601 encoded date and time to a GTimeVal and
  183. -- puts it into time_.
  184. -- iso_date : a ISO 8601 encoded date string
  185. -- time_ : a GTimeVal
  186. -- Returns : TRUE if the conversion was successful.
  187. -- Since 2.12
  188. -- ---------------------------------------------------------------------------------
  189. -- g_time_val_to_iso8601 ()
  190. -- gchar* g_time_val_to_iso8601 (GTimeVal *time_);
  191. -- Converts time_ into a ISO 8601 encoded string, relative to the Coordinated
  192. -- Universal Time (UTC).
  193. -- time_ : a GTimeVal
  194. -- Returns : a newly allocated string containing a ISO 8601 date
  195. -- Since 2.12
  196. -- ---------------------------------------------------------------------------------
  197. -- GDate
  198. -- typedef struct {
  199. -- guint julian_days : 32; /* julian days representation - we use a
  200. -- * bitfield hoping that 64 bit platforms
  201. -- * will pack this whole struct in one big
  202. -- * int
  203. -- */
  204. -- guint julian : 1; /* julian is valid */
  205. -- guint dmy : 1; /* dmy is valid */
  206. -- /* DMY representation */
  207. -- guint day : 6;
  208. -- guint month : 4;
  209. -- guint year : 16;
  210. -- } GDate;
  211. -- Represents a day between January 1, Year 1 and a few thousand years in the
  212. -- future. None of its members should be accessed directly. If the GDate is obtained
  213. -- from g_date_new(), it will be safe to mutate but invalid and thus not safe for
  214. -- calendrical computations. If it's declared on the stack, it will contain garbage
  215. -- so must be initialized with g_date_clear(). g_date_clear() makes the date invalid
  216. -- but sane. An invalid date doesn't represent a day, it's "empty." A date becomes
  217. -- valid after you set it to a Julian day or you set a day, month, and year.
  218. -- guint julian_days : 32; the Julian representation of the date
  219. -- guint julian : 1; this bit is set if julian_days is valid
  220. -- guint dmy : 1; this is set if day, month and year are valid
  221. -- guint day : 6; the day of the day-month-year representation of the date,
  222. -- as a number between 1 and 31
  223. -- guint month : 4; the day of the day-month-year representation of the date,
  224. -- as a number between 1 and 12
  225. -- guint year : 16; the day of the day-month-year representation of the date
  226. -- ---------------------------------------------------------------------------------
  227. -- GTime
  228. -- typedef gint32 GTime;
  229. -- Simply a replacement for time_t. It has been deprected since it is not equivalent
  230. -- to time_t on 64-bit platforms with a 64-bit time_t. Unrelated to GTimer.
  231. -- Note that GTime is defined to always be a 32bit integer, unlike time_t which may
  232. -- be 64bit on some systems. Therefore, GTime will overflow in the year 2038, and
  233. -- you cannot use the address of a GTime variable as argument to the UNIX time()
  234. -- function. Instead, do the following:
  235. -- time_t ttime;
  236. -- GTime gtime;
  237. -- time (&ttime);
  238. -- gtime = (GTime)ttime;
  239. -- ---------------------------------------------------------------------------------
  240. -- enum GDateDMY
  241. -- typedef enum
  242. -- {
  243. -- G_DATE_DAY = 0,
  244. -- G_DATE_MONTH = 1,
  245. -- G_DATE_YEAR = 2
  246. -- } GDateDMY;
  247. -- This enumeration isn't used in the API, but may be useful if you need to mark a
  248. -- number as a day, month, or year.
  249. -- G_DATE_DAY a day
  250. -- G_DATE_MONTH a month
  251. -- G_DATE_YEAR a year
  252. -- ---------------------------------------------------------------------------------
  253. -- GDateDay
  254. -- typedef guint8 GDateDay; /* day of the month */
  255. -- Integer representing a day of the month; between 1 and 31. G_DATE_BAD_DAY
  256. -- represents an invalid day of the month.
  257. -- ---------------------------------------------------------------------------------
  258. -- enum GDateMonth
  259. -- typedef enum
  260. -- {
  261. -- G_DATE_BAD_MONTH = 0,
  262. -- G_DATE_JANUARY = 1,
  263. -- G_DATE_FEBRUARY = 2,
  264. -- G_DATE_MARCH = 3,
  265. -- G_DATE_APRIL = 4,
  266. -- G_DATE_MAY = 5,
  267. -- G_DATE_JUNE = 6,
  268. -- G_DATE_JULY = 7,
  269. -- G_DATE_AUGUST = 8,
  270. -- G_DATE_SEPTEMBER = 9,
  271. -- G_DATE_OCTOBER = 10,
  272. -- G_DATE_NOVEMBER = 11,
  273. -- G_DATE_DECEMBER = 12
  274. -- } GDateMonth;
  275. -- Enumeration representing a month; values are G_DATE_JANUARY, G_DATE_FEBRUARY,
  276. -- etc. G_DATE_BAD_MONTH is the invalid value.
  277. -- G_DATE_BAD_MONTH invalid value.
  278. -- G_DATE_JANUARY January.
  279. -- G_DATE_FEBRUARY February.
  280. -- G_DATE_MARCH March.
  281. -- G_DATE_APRIL April.
  282. -- G_DATE_MAY May.
  283. -- G_DATE_JUNE June.
  284. -- G_DATE_JULY July.
  285. -- G_DATE_AUGUST August.
  286. -- G_DATE_SEPTEMBER September.
  287. -- G_DATE_OCTOBER October.
  288. -- G_DATE_NOVEMBER November.
  289. -- G_DATE_DECEMBER December.
  290. -- ---------------------------------------------------------------------------------
  291. -- GDateYear
  292. -- typedef guint16 GDateYear;
  293. -- Integer representing a year; G_DATE_BAD_YEAR is the invalid value. The year must
  294. -- be 1 or higher; negative (BC) years are not allowed. The year is represented with
  295. -- four digits.
  296. -- ---------------------------------------------------------------------------------
  297. -- enum GDateWeekday
  298. -- typedef enum
  299. -- {
  300. -- G_DATE_BAD_WEEKDAY = 0,
  301. -- G_DATE_MONDAY = 1,
  302. -- G_DATE_TUESDAY = 2,
  303. -- G_DATE_WEDNESDAY = 3,
  304. -- G_DATE_THURSDAY = 4,
  305. -- G_DATE_FRIDAY = 5,
  306. -- G_DATE_SATURDAY = 6,
  307. -- G_DATE_SUNDAY = 7
  308. -- } GDateWeekday;
  309. -- Enumeration representing a day of the week; G_DATE_MONDAY, G_DATE_TUESDAY, etc.
  310. -- G_DATE_BAD_WEEKDAY is an invalid weekday.
  311. -- G_DATE_BAD_WEEKDAY invalid value.
  312. -- G_DATE_MONDAY Monday.
  313. -- G_DATE_TUESDAY Tuesday.
  314. -- G_DATE_WEDNESDAY Wednesday.
  315. -- G_DATE_THURSDAY Thursday.
  316. -- G_DATE_FRIDAY Friday.
  317. -- G_DATE_SATURDAY Saturday.
  318. -- G_DATE_SUNDAY Sunday.
  319. -- ---------------------------------------------------------------------------------
  320. -- G_DATE_BAD_DAY
  321. -- #define G_DATE_BAD_DAY 0U
  322. -- Represents an invalid GDateDay.
  323. -- ---------------------------------------------------------------------------------
  324. -- G_DATE_BAD_JULIAN
  325. -- #define G_DATE_BAD_JULIAN 0U
  326. -- Represents an invalid Julian day number.
  327. -- ---------------------------------------------------------------------------------
  328. -- G_DATE_BAD_YEAR
  329. -- #define G_DATE_BAD_YEAR 0U
  330. -- Represents an invalid year.
  331. -- ---------------------------------------------------------------------------------
  332. -- g_date_new ()
  333. -- GDate* g_date_new (void);
  334. -- Allocates a GDate and initializes it to a sane state. The new date will be
  335. -- cleared (as if you'd called g_date_clear()) but invalid (it won't represent an
  336. -- existing day). Free the return value with g_date_free().
  337. -- Returns : a newly-allocated GDate.
  338. -- ---------------------------------------------------------------------------------
  339. -- g_date_new_dmy ()
  340. -- GDate* g_date_new_dmy (GDateDay day,
  341. -- GDateMonth month,
  342. -- GDateYear year);
  343. -- Like g_date_new(), but also sets the value of the date. Assuming the
  344. -- day-month-year triplet you pass in represents an existing day, the returned date
  345. -- will be valid.
  346. -- day : day of the month.
  347. -- month : month of the year.
  348. -- year : year
  349. -- Returns : a newly-allocated GDate initialized with day, month, and year.
  350. -- ---------------------------------------------------------------------------------
  351. -- g_date_new_julian ()
  352. -- GDate* g_date_new_julian (guint32 julian_day);
  353. -- Like g_date_new(), but also sets the value of the date. Assuming the Julian day
  354. -- number you pass in is valid (greater than 0, less than an unreasonably large
  355. -- number), the returned date will be valid.
  356. -- julian_day : days since January 1, Year 1.
  357. -- Returns : a newly-allocated GDate initialized with julian_day.
  358. -- ---------------------------------------------------------------------------------
  359. -- g_date_clear ()
  360. -- void g_date_clear (GDate *date,
  361. -- guint n_dates);
  362. -- Initializes one or more GDate structs to a sane but invalid state. The cleared
  363. -- dates will not represent an existing date, but will not contain garbage. Useful
  364. -- to init a date declared on the stack. Validity can be tested with g_date_valid().
  365. -- date : pointer to one or more dates to clear.
  366. -- n_dates : number of dates to clear.
  367. -- ---------------------------------------------------------------------------------
  368. -- g_date_free ()
  369. -- void g_date_free (GDate *date);
  370. -- Frees a GDate returned from g_date_new().
  371. -- date : a GDate.
  372. -- ---------------------------------------------------------------------------------
  373. -- g_date_set_day ()
  374. -- void g_date_set_day (GDate *date,
  375. -- GDateDay day);
  376. -- Sets the day of the month for a GDate. If the resulting day-month-year triplet is
  377. -- invalid, the date will be invalid.
  378. -- date : a GDate.
  379. -- day : day to set.
  380. -- ---------------------------------------------------------------------------------
  381. -- g_date_set_month ()
  382. -- void g_date_set_month (GDate *date,
  383. -- GDateMonth month);
  384. -- Sets the month of the year for a GDate. If the resulting day-month-year triplet
  385. -- is invalid, the date will be invalid.
  386. -- date : a GDate.
  387. -- month : month to set.
  388. -- ---------------------------------------------------------------------------------
  389. -- g_date_set_year ()
  390. -- void g_date_set_year (GDate *date,
  391. -- GDateYear year);
  392. -- Sets the year for a GDate. If the resulting day-month-year triplet is invalid,
  393. -- the date will be invalid.
  394. -- date : a GDate.
  395. -- year : year to set.
  396. -- ---------------------------------------------------------------------------------
  397. -- g_date_set_dmy ()
  398. -- void g_date_set_dmy (GDate *date,
  399. -- GDateDay day,
  400. -- GDateMonth month,
  401. -- GDateYear y);
  402. -- Sets the value of a GDate from a day, month, and year. The day-month-year triplet
  403. -- must be valid; if you aren't sure it is, call g_date_valid_dmy() to check before
  404. -- you set it.
  405. -- date : a GDate.
  406. -- day : day.
  407. -- month : month.
  408. -- y : year.
  409. -- ---------------------------------------------------------------------------------
  410. -- g_date_set_julian ()
  411. -- void g_date_set_julian (GDate *date,
  412. -- guint32 julian_date);
  413. -- Sets the value of a GDate from a Julian day number.
  414. -- date : a GDate.
  415. -- julian_date : Julian day number (days since January 1, Year 1).
  416. -- ---------------------------------------------------------------------------------
  417. -- g_date_set_time ()
  418. -- void g_date_set_time (GDate *date,
  419. -- GTime time_);
  420. -- Warning
  421. -- g_date_set_time is deprecated and should not be used in newly-written code.
  422. -- Sets the value of a date from a GTime value.
  423. -- Deprecated:2.10: Use g_date_set_time_t() instead.
  424. -- date : a GDate.
  425. -- time_ : GTime value to set.
  426. -- ---------------------------------------------------------------------------------
  427. -- g_date_set_time_t ()
  428. -- void g_date_set_time_t (GDate *date,
  429. -- time_t timet);
  430. -- Sets the value of a date from a time_t value.
  431. -- To set the value of a date to the current day, you could write:
  432. -- g_date_set_time_t (date, time (NULL));
  433. -- date : a GDate
  434. -- timet : time_t value to set
  435. -- Since 2.10
  436. -- ---------------------------------------------------------------------------------
  437. -- g_date_set_time_val ()
  438. -- void g_date_set_time_val (GDate *date,
  439. -- GTimeVal *timeval);
  440. -- Sets the value of a date from a GTimeVal value. Note that the tv_usec member is
  441. -- ignored, because GDate can't make use of the additional precision.
  442. -- date : a GDate
  443. -- timeval : GTimeVal value to set
  444. -- Since 2.10
  445. -- ---------------------------------------------------------------------------------
  446. -- g_date_set_parse ()
  447. -- void g_date_set_parse (GDate *date,
  448. -- const gchar *str);
  449. -- Parses a user-inputted string str, and try to figure out what date it represents,
  450. -- taking the current locale into account. If the string is successfully parsed, the
  451. -- date will be valid after the call. Otherwise, it will be invalid. You should
  452. -- check using g_date_valid() to see whether the parsing succeeded.
  453. -- This function is not appropriate for file formats and the like; it isn't very
  454. -- precise, and its exact behavior varies with the locale. It's intended to be a
  455. -- heuristic routine that guesses what the user means by a given string (and it does
  456. -- work pretty well in that capacity).
  457. -- date : a GDate to fill in.
  458. -- str : string to parse.
  459. -- ---------------------------------------------------------------------------------
  460. -- g_date_add_days ()
  461. -- void g_date_add_days (GDate *date,
  462. -- guint n_days);
  463. -- Increments a date some number of days. To move forward by weeks, add weeks*7
  464. -- days. The date must be valid.
  465. -- date : a GDate to increment.
  466. -- n_days : number of days to move the date forward.
  467. -- ---------------------------------------------------------------------------------
  468. -- g_date_subtract_days ()
  469. -- void g_date_subtract_days (GDate *date,
  470. -- guint n_days);
  471. -- Moves a date some number of days into the past. To move by weeks, just move by
  472. -- weeks*7 days. The date must be valid.
  473. -- date : a GDate to decrement.
  474. -- n_days : number of days to move.
  475. -- ---------------------------------------------------------------------------------
  476. -- g_date_add_months ()
  477. -- void g_date_add_months (GDate *date,
  478. -- guint n_months);
  479. -- Increments a date by some number of months. If the day of the month is greater
  480. -- than 28, this routine may change the day of the month (because the destination
  481. -- month may not have the current day in it). The date must be valid.
  482. -- date : a GDate to increment.
  483. -- n_months : number of months to move forward.
  484. -- ---------------------------------------------------------------------------------
  485. -- g_date_subtract_months ()
  486. -- void g_date_subtract_months (GDate *date,
  487. -- guint n_months);
  488. -- Moves a date some number of months into the past. If the current day of the month
  489. -- doesn't exist in the destination month, the day of the month may change. The date
  490. -- must be valid.
  491. -- date : a GDate to decrement.
  492. -- n_months : number of months to move.
  493. -- ---------------------------------------------------------------------------------
  494. -- g_date_add_years ()
  495. -- void g_date_add_years (GDate *date,
  496. -- guint n_years);
  497. -- Increments a date by some number of years. If the date is February 29, and the
  498. -- destination year is not a leap year, the date will be changed to February 28. The
  499. -- date must be valid.
  500. -- date : a GDate to increment.
  501. -- n_years : number of years to move forward.
  502. -- ---------------------------------------------------------------------------------
  503. -- g_date_subtract_years ()
  504. -- void g_date_subtract_years (GDate *date,
  505. -- guint n_years);
  506. -- Moves a date some number of years into the past. If the current day doesn't exist
  507. -- in the destination year (i.e. it's February 29 and you move to a non-leap-year)
  508. -- then the day is changed to February 29. The date must be valid.
  509. -- date : a GDate to decrement.
  510. -- n_years : number of years to move.
  511. -- ---------------------------------------------------------------------------------
  512. -- g_date_days_between ()
  513. -- gint g_date_days_between (const GDate *date1,
  514. -- const GDate *date2);
  515. -- Computes the number of days between two dates. If date2 is prior to date1, the
  516. -- returned value is negative. Both dates must be valid.
  517. -- date1 : the first date.
  518. -- date2 : the second date.
  519. -- Returns : the number of days between date1 and date2.
  520. -- ---------------------------------------------------------------------------------
  521. -- g_date_compare ()
  522. -- gint g_date_compare (const GDate *lhs,
  523. -- const GDate *rhs);
  524. -- qsort()-style comparsion function for dates. Both dates must be valid.
  525. -- lhs : first date to compare.
  526. -- rhs : second date to compare.
  527. -- Returns : 0 for equal, less than zero if lhs is less than rhs, greater than zero
  528. -- if lhs is greater than rhs.
  529. -- ---------------------------------------------------------------------------------
  530. -- g_date_clamp ()
  531. -- void g_date_clamp (GDate *date,
  532. -- const GDate *min_date,
  533. -- const GDate *max_date);
  534. -- If date is prior to min_date, sets date equal to min_date. If date falls after
  535. -- max_date, sets date equal to max_date. Either min_date and max_date may be NULL.
  536. -- All non-NULL dates must be valid.
  537. -- date : a GDate to clamp.
  538. -- min_date : minimum accepted value for date.
  539. -- max_date : maximum accepted value for date.
  540. -- ---------------------------------------------------------------------------------
  541. -- g_date_order ()
  542. -- void g_date_order (GDate *date1,
  543. -- GDate *date2);
  544. -- Checks if date1 is less than or equal to date2, and swap the values if this is
  545. -- not the case.
  546. -- date1 : the first date.
  547. -- date2 : the second date.
  548. -- ---------------------------------------------------------------------------------
  549. -- g_date_get_day ()
  550. -- GDateDay g_date_get_day (const GDate *date);
  551. -- Returns the day of the month. The date must be valid.
  552. -- date : a GDate to extract the day of the month from.
  553. -- Returns : day of the month.
  554. -- ---------------------------------------------------------------------------------
  555. -- g_date_get_month ()
  556. -- GDateMonth g_date_get_month (const GDate *date);
  557. -- Returns the month of the year. The date must be valid.
  558. -- date : a GDate to get the month from.
  559. -- Returns : month of the year as a GDateMonth.
  560. -- ---------------------------------------------------------------------------------
  561. -- g_date_get_year ()
  562. -- GDateYear g_date_get_year (const GDate *date);
  563. -- Returns the year of a GDate. The date must be valid.
  564. -- date : a GDate.
  565. -- Returns : year in which the date falls.
  566. -- ---------------------------------------------------------------------------------
  567. -- g_date_get_julian ()
  568. -- guint32 g_date_get_julian (const GDate *date);
  569. -- Returns the Julian day or "serial number" of the GDate. The Julian day is simply
  570. -- the number of days since January 1, Year 1; i.e., January 1, Year 1 is Julian day
  571. -- 1; January 2, Year 1 is Julian day 2, etc. The date must be valid.
  572. -- date : a GDate to extract the Julian day from.
  573. -- Returns : Julian day.
  574. -- ---------------------------------------------------------------------------------
  575. -- g_date_get_weekday ()
  576. -- GDateWeekday g_date_get_weekday (const GDate *date);
  577. -- Returns the day of the week for a GDate. The date must be valid.
  578. -- date : a GDate.
  579. -- Returns : day of the week as a GDateWeekday.
  580. -- ---------------------------------------------------------------------------------
  581. -- g_date_get_day_of_year ()
  582. -- guint g_date_get_day_of_year (const GDate *date);
  583. -- Returns the day of the year, where Jan 1 is the first day of the year. The date
  584. -- must be valid.
  585. -- date : a GDate to extract day of year from.
  586. -- Returns : day of the year.
  587. -- ---------------------------------------------------------------------------------
  588. -- g_date_get_days_in_month ()
  589. -- guint8 g_date_get_days_in_month (GDateMonth month,
  590. -- GDateYear year);
  591. -- Returns the number of days in a month, taking leap years into account.
  592. -- month : month.
  593. -- year : year.
  594. -- Returns : number of days in month during the year.
  595. -- ---------------------------------------------------------------------------------
  596. -- g_date_is_first_of_month ()
  597. -- gboolean g_date_is_first_of_month (const GDate *date);
  598. -- Returns TRUE if the date is on the first of a month. The date must be valid.
  599. -- date : a GDate to check.
  600. -- Returns : TRUE if the date is the first of the month.
  601. -- ---------------------------------------------------------------------------------
  602. -- g_date_is_last_of_month ()
  603. -- gboolean g_date_is_last_of_month (const GDate *date);
  604. -- Returns TRUE if the date is the last day of the month. The date must be valid.
  605. -- date : a GDate to check.
  606. -- Returns : TRUE if the date is the last day of the month.
  607. -- ---------------------------------------------------------------------------------
  608. -- g_date_is_leap_year ()
  609. -- gboolean g_date_is_leap_year (GDateYear year);
  610. -- Returns TRUE if the year is a leap year.
  611. -- year : year to check.
  612. -- Returns : TRUE if the year is a leap year.
  613. -- ---------------------------------------------------------------------------------
  614. -- g_date_get_monday_week_of_year ()
  615. -- guint g_date_get_monday_week_of_year (const GDate *date);
  616. -- Returns the week of the year, where weeks are understood to start on Monday. If
  617. -- the date is before the first Monday of the year, return 0. The date must be
  618. -- valid.
  619. -- date : a GDate.
  620. -- Returns : week of the year.
  621. -- ---------------------------------------------------------------------------------
  622. -- g_date_get_monday_weeks_in_year ()
  623. -- guint8 g_date_get_monday_weeks_in_year (GDateYear year);
  624. -- Returns the number of weeks in the year, where weeks are taken to start on
  625. -- Monday. Will be 52 or 53. The date must be valid. (Years always have 52 7-day
  626. -- periods, plus 1 or 2 extra days depending on whether it's a leap year. This
  627. -- function is basically telling you how many Mondays are in the year, i.e. there
  628. -- are 53 Mondays if one of the extra days happens to be a Monday.)
  629. -- year : a year.
  630. -- Returns : number of Mondays in the year.
  631. -- ---------------------------------------------------------------------------------
  632. -- g_date_get_sunday_week_of_year ()
  633. -- guint g_date_get_sunday_week_of_year (const GDate *date);
  634. -- Returns the week of the year during which this date falls, if weeks are
  635. -- understood to being on Sunday. The date must be valid. Can return 0 if the day is
  636. -- before the first Sunday of the year.
  637. -- date : a GDate.
  638. -- Returns : week number.
  639. -- ---------------------------------------------------------------------------------
  640. -- g_date_get_sunday_weeks_in_year ()
  641. -- guint8 g_date_get_sunday_weeks_in_year (GDateYear year);
  642. -- Returns the number of weeks in the year, where weeks are taken to start on
  643. -- Sunday. Will be 52 or 53. The date must be valid. (Years always have 52 7-day
  644. -- periods, plus 1 or 2 extra days depending on whether it's a leap year. This
  645. -- function is basically telling you how many Sundays are in the year, i.e. there
  646. -- are 53 Sundays if one of the extra days happens to be a Sunday.)
  647. -- year : year to count weeks in.
  648. -- Returns : number of weeks.
  649. -- ---------------------------------------------------------------------------------
  650. -- g_date_get_iso8601_week_of_year ()
  651. -- guint g_date_get_iso8601_week_of_year (const GDate *date);
  652. -- Returns the week of the year, where weeks are interpreted according to ISO 8601.
  653. -- date : a valid GDate
  654. -- Returns : ISO 8601 week number of the year.
  655. -- Since 2.6
  656. -- ---------------------------------------------------------------------------------
  657. -- g_date_strftime ()
  658. -- gsize g_date_strftime (gchar *s,
  659. -- gsize slen,
  660. -- const gchar *format,
  661. -- const GDate *date);
  662. -- Generates a printed representation of the date, in a locale-specific way. Works
  663. -- just like the platform's C library strftime() function, but only accepts
  664. -- date-related formats; time-related formats give undefined results. Date must be
  665. -- valid. Unlike strftime() (which uses the locale encoding), works on a UTF-8
  666. -- format string and stores a UTF-8 result.
  667. -- This function does not provide any conversion specifiers in addition to those
  668. -- implemented by the platform's C library. For example, don't expect that using
  669. -- g_date_strftime() would make the F provided by the C99 strftime() work on Windows
  670. -- where the C library only complies to C89.
  671. -- s : destination buffer.
  672. -- slen : buffer size.
  673. -- format : format string.
  674. -- date : valid GDate.
  675. -- Returns : number of characters written to the buffer, or 0 the buffer was too
  676. -- small.
  677. -- ---------------------------------------------------------------------------------
  678. -- g_date_to_struct_tm ()
  679. -- void g_date_to_struct_tm (const GDate *date,
  680. -- struct tm *tm);
  681. -- Fills in the date-related bits of a struct tm using the date value. Initializes
  682. -- the non-date parts with something sane but meaningless.
  683. -- date : a GDate to set the struct tm from.
  684. -- tm : struct tm to fill.
  685. -- ---------------------------------------------------------------------------------
  686. -- g_date_valid ()
  687. -- gboolean g_date_valid (const GDate *date);
  688. -- Returns TRUE if the GDate represents an existing day. The date must not contain
  689. -- garbage; it should have been initialized with g_date_clear() if it wasn't
  690. -- allocated by one of the g_date_new() variants.
  691. -- date : a GDate to check.
  692. -- Returns : Whether the date is valid.
  693. -- ---------------------------------------------------------------------------------
  694. -- g_date_valid_day ()
  695. -- gboolean g_date_valid_day (GDateDay day);
  696. -- Returns TRUE if the day of the month is valid (a day is valid if it's between 1
  697. -- and 31 inclusive).
  698. -- day : day to check.
  699. -- Returns : TRUE if the day is valid.
  700. -- ---------------------------------------------------------------------------------
  701. -- g_date_valid_month ()
  702. -- gboolean g_date_valid_month (GDateMonth month);
  703. -- Returns TRUE if the month value is valid. The 12 GDateMonth enumeration values
  704. -- are the only valid months.
  705. -- month : month.
  706. -- Returns : TRUE if the month is valid.
  707. -- ---------------------------------------------------------------------------------
  708. -- g_date_valid_year ()
  709. -- gboolean g_date_valid_year (GDateYear year);
  710. -- Returns TRUE if the year is valid. Any year greater than 0 is valid, though there
  711. -- is a 16-bit limit to what GDate will understand.
  712. -- year : year.
  713. -- Returns : TRUE if the year is valid.
  714. -- ---------------------------------------------------------------------------------
  715. -- g_date_valid_dmy ()
  716. -- gboolean g_date_valid_dmy (GDateDay day,
  717. -- GDateMonth month,
  718. -- GDateYear year);
  719. -- Returns TRUE if the day-month-year triplet forms a valid, existing day in the
  720. -- range of days GDate understands (Year 1 or later, no more than a few thousand
  721. -- years in the future).
  722. -- day : day.
  723. -- month : month.
  724. -- year : year.
  725. -- Returns : TRUE if the date is a valid one.
  726. -- ---------------------------------------------------------------------------------
  727. -- g_date_valid_julian ()
  728. -- gboolean g_date_valid_julian (guint32 julian_date);
  729. -- Returns TRUE if the Julian day is valid. Anything greater than zero is basically
  730. -- a valid Julian, though there is a 32-bit limit.
  731. -- julian_date : Julian day to check.
  732. -- Returns : TRUE if the Julian day is valid.
  733. -- ---------------------------------------------------------------------------------
  734. -- g_date_valid_weekday ()
  735. -- gboolean g_date_valid_weekday (GDateWeekday weekday);
  736. -- Returns TRUE if the weekday is valid. The 7 GDateWeekday enumeration values are
  737. -- the only valid weekdays.
  738. -- weekday : weekday.
  739. -- Returns : TRUE if the weekday is valid.
  740. end -- class GLIB_DATE_AND_TIME_FUNCTIONS