1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = 
27  * outPack = glib
28  * outFile = Date
29  * strct   = GDate
30  * realStrct=
31  * ctorStrct=
32  * clss    = Date
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_date_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- gtkc.Loader
48  * 	- gtkc.paths
49  * structWrap:
50  * 	- GDate* -> Date
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module glib.Date;
57 
58 public  import gtkc.glibtypes;
59 
60 private import gtkc.glib;
61 private import glib.ConstructionException;
62 
63 private import glib.Str;
64 private import gtkc.Loader;
65 private import gtkc.paths;
66 
67 
68 
69 /**
70  * The GDate data structure represents a day between January 1, Year 1,
71  * and sometime a few thousand years in the future (right now it will go
72  * to the year 65535 or so, but g_date_set_parse() only parses up to the
73  * year 8000 or so - just count on "a few thousand"). GDate is meant to
74  * represent everyday dates, not astronomical dates or historical dates
75  * or ISO timestamps or the like. It extrapolates the current Gregorian
76  * calendar forward and backward in time; there is no attempt to change
77  * the calendar to match time periods or locations. GDate does not store
78  * time information; it represents a day.
79  *
80  * The GDate implementation has several nice features; it is only a
81  * 64-bit struct, so storing large numbers of dates is very efficient. It
82  * can keep both a Julian and day-month-year representation of the date,
83  * since some calculations are much easier with one representation or the
84  * other. A Julian representation is simply a count of days since some
85  * fixed day in the past; for GDate the fixed day is January 1, 1 AD.
86  * ("Julian" dates in the GDate API aren't really Julian dates in the
87  * technical sense; technically, Julian dates count from the start of the
88  * Julian period, Jan 1, 4713 BC).
89  *
90  * GDate is simple to use. First you need a "blank" date; you can get a
91  * dynamically allocated date from g_date_new(), or you can declare an
92  * automatic variable or array and initialize it to a sane state by
93  * calling g_date_clear(). A cleared date is sane; it's safe to call
94  * g_date_set_dmy() and the other mutator functions to initialize the
95  * value of a cleared date. However, a cleared date is initially
96  * invalid, meaning that it doesn't represent a day
97  * that exists. It is undefined to call any of the date calculation
98  * routines on an invalid date. If you obtain a date from a user or other
99  * unpredictable source, you should check its validity with the
100  * g_date_valid() predicate. g_date_valid() is also used to check for
101  * errors with g_date_set_parse() and other functions that can
102  * fail. Dates can be invalidated by calling g_date_clear() again.
103  *
104  * It is very important to use the API to access the GDate
105  * struct. Often only the day-month-year or only the Julian
106  * representation is valid. Sometimes neither is valid. Use the API.
107  *
108  * GLib also features GDateTime which represents a precise time.
109  */
110 public class Date
111 {
112 	
113 	/** the main Gtk struct */
114 	protected GDate* gDate;
115 	
116 	
117 	/** Get the main Gtk struct */
118 	public GDate* getDateStruct()
119 	{
120 		return gDate;
121 	}
122 	
123 	
124 	/** the main Gtk struct as a void* */
125 	protected void* getStruct()
126 	{
127 		return cast(void*)gDate;
128 	}
129 	
130 	/**
131 	 * Sets our main struct and passes it to the parent class
132 	 */
133 	public this (GDate* gDate)
134 	{
135 		this.gDate = gDate;
136 	}
137 	
138 	~this ()
139 	{
140 		if ( Linker.isLoaded(LIBRARY.GLIB) && gDate !is null )
141 		{
142 			g_date_free(gDate);
143 		}
144 	}
145 	
146 	/**
147 	 */
148 	
149 	/**
150 	 * Allocates a GDate and initializes
151 	 * it to a sane state. The new date will
152 	 * be cleared (as if you'd called g_date_clear()) but invalid (it won't
153 	 * represent an existing day). Free the return value with g_date_free().
154 	 * Throws: ConstructionException GTK+ fails to create the object.
155 	 */
156 	public this ()
157 	{
158 		// GDate * g_date_new (void);
159 		auto p = g_date_new();
160 		if(p is null)
161 		{
162 			throw new ConstructionException("null returned by g_date_new()");
163 		}
164 		this(cast(GDate*) p);
165 	}
166 	
167 	/**
168 	 * Like g_date_new(), but also sets the value of the date. Assuming the
169 	 * day-month-year triplet you pass in represents an existing day, the
170 	 * returned date will be valid.
171 	 * Params:
172 	 * day = day of the month
173 	 * month = month of the year
174 	 * year = year
175 	 * Throws: ConstructionException GTK+ fails to create the object.
176 	 */
177 	public this (GDateDay day, GDateMonth month, GDateYear year)
178 	{
179 		// GDate * g_date_new_dmy (GDateDay day,  GDateMonth month,  GDateYear year);
180 		auto p = g_date_new_dmy(day, month, year);
181 		if(p is null)
182 		{
183 			throw new ConstructionException("null returned by g_date_new_dmy(day, month, year)");
184 		}
185 		this(cast(GDate*) p);
186 	}
187 	
188 	/**
189 	 * Like g_date_new(), but also sets the value of the date. Assuming the
190 	 * Julian day number you pass in is valid (greater than 0, less than an
191 	 * unreasonably large number), the returned date will be valid.
192 	 * Params:
193 	 * julianDay = days since January 1, Year 1
194 	 * Throws: ConstructionException GTK+ fails to create the object.
195 	 */
196 	public this (uint julianDay)
197 	{
198 		// GDate * g_date_new_julian (guint32 julian_day);
199 		auto p = g_date_new_julian(julianDay);
200 		if(p is null)
201 		{
202 			throw new ConstructionException("null returned by g_date_new_julian(julianDay)");
203 		}
204 		this(cast(GDate*) p);
205 	}
206 	
207 	/**
208 	 * Initializes one or more GDate structs to a sane but invalid
209 	 * state. The cleared dates will not represent an existing date, but will
210 	 * not contain garbage. Useful to init a date declared on the stack.
211 	 * Validity can be tested with g_date_valid().
212 	 * Params:
213 	 * nDates = number of dates to clear
214 	 */
215 	public void clear(uint nDates)
216 	{
217 		// void g_date_clear (GDate *date,  guint n_dates);
218 		g_date_clear(gDate, nDates);
219 	}
220 	
221 	/**
222 	 * Frees a GDate returned from g_date_new().
223 	 */
224 	public void free()
225 	{
226 		// void g_date_free (GDate *date);
227 		g_date_free(gDate);
228 	}
229 	
230 	/**
231 	 * Sets the day of the month for a GDate. If the resulting
232 	 * day-month-year triplet is invalid, the date will be invalid.
233 	 * Params:
234 	 * day = day to set
235 	 */
236 	public void setDay(GDateDay day)
237 	{
238 		// void g_date_set_day (GDate *date,  GDateDay day);
239 		g_date_set_day(gDate, day);
240 	}
241 	
242 	/**
243 	 * Sets the month of the year for a GDate. If the resulting
244 	 * day-month-year triplet is invalid, the date will be invalid.
245 	 * Params:
246 	 * month = month to set
247 	 */
248 	public void setMonth(GDateMonth month)
249 	{
250 		// void g_date_set_month (GDate *date,  GDateMonth month);
251 		g_date_set_month(gDate, month);
252 	}
253 	
254 	/**
255 	 * Sets the year for a GDate. If the resulting day-month-year
256 	 * triplet is invalid, the date will be invalid.
257 	 * Params:
258 	 * year = year to set
259 	 */
260 	public void setYear(GDateYear year)
261 	{
262 		// void g_date_set_year (GDate *date,  GDateYear year);
263 		g_date_set_year(gDate, year);
264 	}
265 	
266 	/**
267 	 * Sets the value of a GDate from a day, month, and year.
268 	 * The day-month-year triplet must be valid; if you aren't
269 	 * sure it is, call g_date_valid_dmy() to check before you
270 	 * set it.
271 	 * Params:
272 	 * day = day
273 	 * month = month
274 	 * y = year
275 	 */
276 	public void setDmy(GDateDay day, GDateMonth month, GDateYear y)
277 	{
278 		// void g_date_set_dmy (GDate *date,  GDateDay day,  GDateMonth month,  GDateYear y);
279 		g_date_set_dmy(gDate, day, month, y);
280 	}
281 	
282 	/**
283 	 * Sets the value of a GDate from a Julian day number.
284 	 * Params:
285 	 * julianDate = Julian day number (days since January 1, Year 1)
286 	 */
287 	public void setJulian(uint julianDate)
288 	{
289 		// void g_date_set_julian (GDate *date,  guint32 julian_date);
290 		g_date_set_julian(gDate, julianDate);
291 	}
292 	
293 	/**
294 	 * Warning
295 	 * g_date_set_time has been deprecated since version 2.10 and should not be used in newly-written code. Use g_date_set_time_t() instead.
296 	 * Sets the value of a date from a GTime value.
297 	 * The time to date conversion is done using the user's current timezone.
298 	 * Params:
299 	 * time = GTime value to set.
300 	 */
301 	public void setTime(GTime time)
302 	{
303 		// void g_date_set_time (GDate *date,  GTime time_);
304 		g_date_set_time(gDate, time);
305 	}
306 	
307 	/**
308 	 * Sets the value of a date to the date corresponding to a time
309 	 * specified as a time_t. The time to date conversion is done using
310 	 * the user's current timezone.
311 	 * Since 2.10
312 	 * Params:
313 	 * timet = time_t value to set
314 	 */
315 	public void setTimeT(uint timet)
316 	{
317 		// void g_date_set_time_t (GDate *date,  time_t timet);
318 		g_date_set_time_t(gDate, timet);
319 	}
320 	
321 	/**
322 	 * Sets the value of a date from a GTimeVal value. Note that the
323 	 * tv_usec member is ignored, because GDate can't make use of the
324 	 * additional precision.
325 	 * The time to date conversion is done using the user's current timezone.
326 	 * Since 2.10
327 	 * Params:
328 	 * timeval = GTimeVal value to set
329 	 */
330 	public void setTimeVal(ref GTimeVal timeval)
331 	{
332 		// void g_date_set_time_val (GDate *date,  GTimeVal *timeval);
333 		g_date_set_time_val(gDate, &timeval);
334 	}
335 	
336 	/**
337 	 * Parses a user-inputted string str, and try to figure out what date it
338 	 * represents, taking the current locale
339 	 * into account. If the string is successfully parsed, the date will be
340 	 * valid after the call. Otherwise, it will be invalid. You should check
341 	 * using g_date_valid() to see whether the parsing succeeded.
342 	 * This function is not appropriate for file formats and the like; it
343 	 * isn't very precise, and its exact behavior varies with the locale.
344 	 * It's intended to be a heuristic routine that guesses what the user
345 	 * means by a given string (and it does work pretty well in that
346 	 * capacity).
347 	 * Params:
348 	 * str = string to parse
349 	 */
350 	public void setParse(string str)
351 	{
352 		// void g_date_set_parse (GDate *date,  const gchar *str);
353 		g_date_set_parse(gDate, Str.toStringz(str));
354 	}
355 	
356 	/**
357 	 * Increments a date some number of days.
358 	 * To move forward by weeks, add weeks*7 days.
359 	 * The date must be valid.
360 	 * Params:
361 	 * nDays = number of days to move the date forward
362 	 */
363 	public void addDays(uint nDays)
364 	{
365 		// void g_date_add_days (GDate *date,  guint n_days);
366 		g_date_add_days(gDate, nDays);
367 	}
368 	
369 	/**
370 	 * Moves a date some number of days into the past.
371 	 * To move by weeks, just move by weeks*7 days.
372 	 * The date must be valid.
373 	 * Params:
374 	 * nDays = number of days to move
375 	 */
376 	public void subtractDays(uint nDays)
377 	{
378 		// void g_date_subtract_days (GDate *date,  guint n_days);
379 		g_date_subtract_days(gDate, nDays);
380 	}
381 	
382 	/**
383 	 * Increments a date by some number of months.
384 	 * If the day of the month is greater than 28,
385 	 * this routine may change the day of the month
386 	 * (because the destination month may not have
387 	 * the current day in it). The date must be valid.
388 	 * Params:
389 	 * nMonths = number of months to move forward
390 	 */
391 	public void addMonths(uint nMonths)
392 	{
393 		// void g_date_add_months (GDate *date,  guint n_months);
394 		g_date_add_months(gDate, nMonths);
395 	}
396 	
397 	/**
398 	 * Moves a date some number of months into the past.
399 	 * If the current day of the month doesn't exist in
400 	 * the destination month, the day of the month
401 	 * may change. The date must be valid.
402 	 * Params:
403 	 * nMonths = number of months to move
404 	 */
405 	public void subtractMonths(uint nMonths)
406 	{
407 		// void g_date_subtract_months (GDate *date,  guint n_months);
408 		g_date_subtract_months(gDate, nMonths);
409 	}
410 	
411 	/**
412 	 * Increments a date by some number of years.
413 	 * If the date is February 29, and the destination
414 	 * year is not a leap year, the date will be changed
415 	 * to February 28. The date must be valid.
416 	 * Params:
417 	 * nYears = number of years to move forward
418 	 */
419 	public void addYears(uint nYears)
420 	{
421 		// void g_date_add_years (GDate *date,  guint n_years);
422 		g_date_add_years(gDate, nYears);
423 	}
424 	
425 	/**
426 	 * Moves a date some number of years into the past.
427 	 * If the current day doesn't exist in the destination
428 	 * year (i.e. it's February 29 and you move to a non-leap-year)
429 	 * then the day is changed to February 29. The date
430 	 * must be valid.
431 	 * Params:
432 	 * nYears = number of years to move
433 	 */
434 	public void subtractYears(uint nYears)
435 	{
436 		// void g_date_subtract_years (GDate *date,  guint n_years);
437 		g_date_subtract_years(gDate, nYears);
438 	}
439 	
440 	/**
441 	 * Computes the number of days between two dates.
442 	 * If date2 is prior to date1, the returned value is negative.
443 	 * Both dates must be valid.
444 	 * Params:
445 	 * date2 = the second date
446 	 * Returns: the number of days between date1 and date2
447 	 */
448 	public int daysBetween(Date date2)
449 	{
450 		// gint g_date_days_between (const GDate *date1,  const GDate *date2);
451 		return g_date_days_between(gDate, (date2 is null) ? null : date2.getDateStruct());
452 	}
453 	
454 	/**
455 	 * qsort()-style comparison function for dates.
456 	 * Both dates must be valid.
457 	 * Params:
458 	 * rhs = second date to compare
459 	 * Returns: 0 for equal, less than zero if lhs is less than rhs, greater than zero if lhs is greater than rhs
460 	 */
461 	public int compare(Date rhs)
462 	{
463 		// gint g_date_compare (const GDate *lhs,  const GDate *rhs);
464 		return g_date_compare(gDate, (rhs is null) ? null : rhs.getDateStruct());
465 	}
466 	
467 	/**
468 	 * If date is prior to min_date, sets date equal to min_date.
469 	 * If date falls after max_date, sets date equal to max_date.
470 	 * Otherwise, date is unchanged.
471 	 * Either of min_date and max_date may be NULL.
472 	 * All non-NULL dates must be valid.
473 	 * Params:
474 	 * minDate = minimum accepted value for date
475 	 * maxDate = maximum accepted value for date
476 	 */
477 	public void clamp(Date minDate, Date maxDate)
478 	{
479 		// void g_date_clamp (GDate *date,  const GDate *min_date,  const GDate *max_date);
480 		g_date_clamp(gDate, (minDate is null) ? null : minDate.getDateStruct(), (maxDate is null) ? null : maxDate.getDateStruct());
481 	}
482 	
483 	/**
484 	 * Checks if date1 is less than or equal to date2,
485 	 * and swap the values if this is not the case.
486 	 * Params:
487 	 * date2 = the second date
488 	 */
489 	public void order(Date date2)
490 	{
491 		// void g_date_order (GDate *date1,  GDate *date2);
492 		g_date_order(gDate, (date2 is null) ? null : date2.getDateStruct());
493 	}
494 	
495 	/**
496 	 * Returns the day of the month. The date must be valid.
497 	 * Returns: day of the month
498 	 */
499 	public GDateDay getDay()
500 	{
501 		// GDateDay g_date_get_day (const GDate *date);
502 		return g_date_get_day(gDate);
503 	}
504 	
505 	/**
506 	 * Returns the month of the year. The date must be valid.
507 	 * Returns: month of the year as a GDateMonth
508 	 */
509 	public GDateMonth getMonth()
510 	{
511 		// GDateMonth g_date_get_month (const GDate *date);
512 		return g_date_get_month(gDate);
513 	}
514 	
515 	/**
516 	 * Returns the year of a GDate. The date must be valid.
517 	 * Returns: year in which the date falls
518 	 */
519 	public GDateYear getYear()
520 	{
521 		// GDateYear g_date_get_year (const GDate *date);
522 		return g_date_get_year(gDate);
523 	}
524 	
525 	/**
526 	 * Returns the Julian day or "serial number" of the GDate. The
527 	 * Julian day is simply the number of days since January 1, Year 1; i.e.,
528 	 * January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
529 	 * etc. The date must be valid.
530 	 * Returns: Julian day
531 	 */
532 	public uint getJulian()
533 	{
534 		// guint32 g_date_get_julian (const GDate *date);
535 		return g_date_get_julian(gDate);
536 	}
537 	
538 	/**
539 	 * Returns the day of the week for a GDate. The date must be valid.
540 	 * Returns: day of the week as a GDateWeekday.
541 	 */
542 	public GDateWeekday getWeekday()
543 	{
544 		// GDateWeekday g_date_get_weekday (const GDate *date);
545 		return g_date_get_weekday(gDate);
546 	}
547 	
548 	/**
549 	 * Returns the day of the year, where Jan 1 is the first day of the
550 	 * year. The date must be valid.
551 	 * Returns: day of the year
552 	 */
553 	public uint getDayOfYear()
554 	{
555 		// guint g_date_get_day_of_year (const GDate *date);
556 		return g_date_get_day_of_year(gDate);
557 	}
558 	
559 	/**
560 	 * Returns the number of days in a month, taking leap
561 	 * years into account.
562 	 * Params:
563 	 * month = month
564 	 * year = year
565 	 * Returns: number of days in month during the year
566 	 */
567 	public static ubyte getDaysInMonth(GDateMonth month, GDateYear year)
568 	{
569 		// guint8 g_date_get_days_in_month (GDateMonth month,  GDateYear year);
570 		return g_date_get_days_in_month(month, year);
571 	}
572 	
573 	/**
574 	 * Returns TRUE if the date is on the first of a month.
575 	 * The date must be valid.
576 	 * Returns: TRUE if the date is the first of the month
577 	 */
578 	public int isFirstOfMonth()
579 	{
580 		// gboolean g_date_is_first_of_month (const GDate *date);
581 		return g_date_is_first_of_month(gDate);
582 	}
583 	
584 	/**
585 	 * Returns TRUE if the date is the last day of the month.
586 	 * The date must be valid.
587 	 * Returns: TRUE if the date is the last day of the month
588 	 */
589 	public int isLastOfMonth()
590 	{
591 		// gboolean g_date_is_last_of_month (const GDate *date);
592 		return g_date_is_last_of_month(gDate);
593 	}
594 	
595 	/**
596 	 * Returns TRUE if the year is a leap year.
597 	 * [5]
598 	 * Params:
599 	 * year = year to check
600 	 * Returns: TRUE if the year is a leap year
601 	 */
602 	public static int isLeapYear(GDateYear year)
603 	{
604 		// gboolean g_date_is_leap_year (GDateYear year);
605 		return g_date_is_leap_year(year);
606 	}
607 	
608 	/**
609 	 * Returns the week of the year, where weeks are understood to start on
610 	 * Monday. If the date is before the first Monday of the year, return
611 	 * 0. The date must be valid.
612 	 * Returns: week of the year
613 	 */
614 	public uint getMondayWeekOfYear()
615 	{
616 		// guint g_date_get_monday_week_of_year (const GDate *date);
617 		return g_date_get_monday_week_of_year(gDate);
618 	}
619 	
620 	/**
621 	 * Returns the number of weeks in the year, where weeks
622 	 * are taken to start on Monday. Will be 52 or 53. The
623 	 * date must be valid. (Years always have 52 7-day periods,
624 	 * plus 1 or 2 extra days depending on whether it's a leap
625 	 * year. This function is basically telling you how many
626 	 * Mondays are in the year, i.e. there are 53 Mondays if
627 	 * one of the extra days happens to be a Monday.)
628 	 * Params:
629 	 * year = a year
630 	 * Returns: number of Mondays in the year
631 	 */
632 	public static ubyte getMondayWeeksInYear(GDateYear year)
633 	{
634 		// guint8 g_date_get_monday_weeks_in_year (GDateYear year);
635 		return g_date_get_monday_weeks_in_year(year);
636 	}
637 	
638 	/**
639 	 * Returns the week of the year during which this date falls, if weeks
640 	 * are understood to being on Sunday. The date must be valid. Can return
641 	 * 0 if the day is before the first Sunday of the year.
642 	 * Returns: week number
643 	 */
644 	public uint getSundayWeekOfYear()
645 	{
646 		// guint g_date_get_sunday_week_of_year (const GDate *date);
647 		return g_date_get_sunday_week_of_year(gDate);
648 	}
649 	
650 	/**
651 	 * Returns the number of weeks in the year, where weeks
652 	 * are taken to start on Sunday. Will be 52 or 53. The
653 	 * date must be valid. (Years always have 52 7-day periods,
654 	 * plus 1 or 2 extra days depending on whether it's a leap
655 	 * year. This function is basically telling you how many
656 	 * Sundays are in the year, i.e. there are 53 Sundays if
657 	 * one of the extra days happens to be a Sunday.)
658 	 * Params:
659 	 * year = year to count weeks in
660 	 * Returns: the number of weeks in year
661 	 */
662 	public static ubyte getSundayWeeksInYear(GDateYear year)
663 	{
664 		// guint8 g_date_get_sunday_weeks_in_year (GDateYear year);
665 		return g_date_get_sunday_weeks_in_year(year);
666 	}
667 	
668 	/**
669 	 * Returns the week of the year, where weeks are interpreted according
670 	 * to ISO 8601.
671 	 * Since 2.6
672 	 * Returns: ISO 8601 week number of the year.
673 	 */
674 	public uint getIso8601_WeekOfYear()
675 	{
676 		// guint g_date_get_iso8601_week_of_year (const GDate *date);
677 		return g_date_get_iso8601_week_of_year(gDate);
678 	}
679 	
680 	/**
681 	 * Generates a printed representation of the date, in a
682 	 * locale-specific way.
683 	 * Works just like the platform's C library strftime() function,
684 	 * but only accepts date-related formats; time-related formats
685 	 * give undefined results. Date must be valid. Unlike strftime()
686 	 * (which uses the locale encoding), works on a UTF-8 format
687 	 * string and stores a UTF-8 result.
688 	 * This function does not provide any conversion specifiers in
689 	 * addition to those implemented by the platform's C library.
690 	 * For example, don't expect that using g_date_strftime() would
691 	 * make the %F provided by the C99 strftime() work on Windows
692 	 * where the C library only complies to C89.
693 	 * Params:
694 	 * s = destination buffer
695 	 * format = format string
696 	 * date = valid GDate
697 	 * Returns: number of characters written to the buffer, or 0 the buffer was too small
698 	 */
699 	public static gsize strftime(char[] s, string format, Date date)
700 	{
701 		// gsize g_date_strftime (gchar *s,  gsize slen,  const gchar *format,  const GDate *date);
702 		return g_date_strftime(s.ptr, cast(int) s.length, Str.toStringz(format), (date is null) ? null : date.getDateStruct());
703 	}
704 	
705 	/**
706 	 * Fills in the date-related bits of a struct tm
707 	 * using the date value. Initializes the non-date parts with something
708 	 * sane but meaningless.
709 	 * Params:
710 	 * tm = struct tm to fill
711 	 */
712 	public void toStructTm(void* tm)
713 	{
714 		// void g_date_to_struct_tm (const GDate *date,  struct tm *tm);
715 		g_date_to_struct_tm(gDate, tm);
716 	}
717 	
718 	/**
719 	 * Returns TRUE if the GDate represents an existing day. The date must not
720 	 * contain garbage; it should have been initialized with g_date_clear()
721 	 * if it wasn't allocated by one of the g_date_new() variants.
722 	 * Returns: Whether the date is valid
723 	 */
724 	public int valid()
725 	{
726 		// gboolean g_date_valid (const GDate *date);
727 		return g_date_valid(gDate);
728 	}
729 	
730 	/**
731 	 * Returns TRUE if the day of the month is valid (a day is valid if it's
732 	 * between 1 and 31 inclusive).
733 	 * Params:
734 	 * day = day to check
735 	 * Returns: TRUE if the day is valid
736 	 */
737 	public static int validDay(GDateDay day)
738 	{
739 		// gboolean g_date_valid_day (GDateDay day);
740 		return g_date_valid_day(day);
741 	}
742 	
743 	/**
744 	 * Returns TRUE if the month value is valid. The 12 GDateMonth
745 	 * enumeration values are the only valid months.
746 	 * Params:
747 	 * month = month
748 	 * Returns: TRUE if the month is valid
749 	 */
750 	public static int validMonth(GDateMonth month)
751 	{
752 		// gboolean g_date_valid_month (GDateMonth month);
753 		return g_date_valid_month(month);
754 	}
755 	
756 	/**
757 	 * Returns TRUE if the year is valid. Any year greater than 0 is valid,
758 	 * though there is a 16-bit limit to what GDate will understand.
759 	 * Params:
760 	 * year = year
761 	 * Returns: TRUE if the year is valid
762 	 */
763 	public static int validYear(GDateYear year)
764 	{
765 		// gboolean g_date_valid_year (GDateYear year);
766 		return g_date_valid_year(year);
767 	}
768 	
769 	/**
770 	 * Returns TRUE if the day-month-year triplet forms a valid, existing day
771 	 * in the range of days GDate understands (Year 1 or later, no more than
772 	 * a few thousand years in the future).
773 	 * Params:
774 	 * day = day
775 	 * month = month
776 	 * year = year
777 	 * Returns: TRUE if the date is a valid one
778 	 */
779 	public static int validDmy(GDateDay day, GDateMonth month, GDateYear year)
780 	{
781 		// gboolean g_date_valid_dmy (GDateDay day,  GDateMonth month,  GDateYear year);
782 		return g_date_valid_dmy(day, month, year);
783 	}
784 	
785 	/**
786 	 * Returns TRUE if the Julian day is valid. Anything greater than zero
787 	 * is basically a valid Julian, though there is a 32-bit limit.
788 	 * Params:
789 	 * julianDate = Julian day to check
790 	 * Returns: TRUE if the Julian day is valid
791 	 */
792 	public static int validJulian(uint julianDate)
793 	{
794 		// gboolean g_date_valid_julian (guint32 julian_date);
795 		return g_date_valid_julian(julianDate);
796 	}
797 	
798 	/**
799 	 * Returns TRUE if the weekday is valid. The seven GDateWeekday enumeration
800 	 * values are the only valid weekdays.
801 	 * Params:
802 	 * weekday = weekday
803 	 * Returns: TRUE if the weekday is valid [5] For the purposes of this function, leap year is every year divisible by 4 unless that year is divisible by 100. If it is divisible by 100 it would be a leap year only if that year is also divisible by 400.
804 	 */
805 	public static int validWeekday(GDateWeekday weekday)
806 	{
807 		// gboolean g_date_valid_weekday (GDateWeekday weekday);
808 		return g_date_valid_weekday(weekday);
809 	}
810 }