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  = glib-GDateTime.html
27  * outPack = glib
28  * outFile = DateTime
29  * strct   = GDateTime
30  * realStrct=
31  * ctorStrct=
32  * clss    = DateTime
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_date_time_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * 	- g_date_time_new_now_utc
45  * 	- g_date_time_new_now_local
46  * 	- g_date_time_new_from_unix_local
47  * 	- g_date_time_new_from_unix_utc
48  * 	- g_date_time_new_from_timeval_local
49  * 	- g_date_time_new_from_timeval_utc
50  * 	- g_date_time_new_local
51  * 	- g_date_time_new_utc
52  * 	- g_date_time_hash
53  * omit signals:
54  * imports:
55  * 	- glib.Str
56  * 	- glib.TimeZone
57  * 	- gtkc.Loader
58  * 	- gtkc.paths
59  * structWrap:
60  * 	- GDateTime* -> DateTime
61  * 	- GTimeZone* -> TimeZone
62  * 	- void* -> DateTime
63  * module aliases:
64  * local aliases:
65  * overrides:
66  */
67 
68 module glib.DateTime;
69 
70 public  import gtkc.glibtypes;
71 
72 private import gtkc.glib;
73 private import glib.ConstructionException;
74 
75 private import glib.Str;
76 private import glib.TimeZone;
77 private import gtkc.Loader;
78 private import gtkc.paths;
79 
80 
81 
82 /**
83  * GDateTime is a structure that combines a Gregorian date and time
84  * into a single structure. It provides many conversion and methods to
85  * manipulate dates and times. Time precision is provided down to
86  * microseconds and the time can range (proleptically) from 0001-01-01
87  * 00:00:00 to 9999-12-31 23:59:59.999999. GDateTime follows POSIX
88  * time in the sense that it is oblivious to leap seconds.
89  *
90  * GDateTime is an immutable object; once it has been created it cannot
91  * be modified further. All modifiers will create a new GDateTime.
92  * Nearly all such functions can fail due to the date or time going out
93  * of range, in which case NULL will be returned.
94  *
95  * GDateTime is reference counted: the reference count is increased by calling
96  * g_date_time_ref() and decreased by calling g_date_time_unref(). When the
97  * reference count drops to 0, the resources allocated by the GDateTime
98  * structure are released.
99  *
100  * Many parts of the API may produce non-obvious results. As an
101  * example, adding two months to January 31st will yield March 31st
102  * whereas adding one month and then one month again will yield either
103  * March 28th or March 29th. Also note that adding 24 hours is not
104  * always the same as adding one day (since days containing daylight
105  * savings time transitions are either 23 or 25 hours in length).
106  *
107  * GDateTime is available since GLib 2.26.
108  */
109 public class DateTime
110 {
111 	
112 	/** the main Gtk struct */
113 	protected GDateTime* gDateTime;
114 	
115 	
116 	/** Get the main Gtk struct */
117 	public GDateTime* getDateTimeStruct()
118 	{
119 		return gDateTime;
120 	}
121 	
122 	
123 	/** the main Gtk struct as a void* */
124 	protected void* getStruct()
125 	{
126 		return cast(void*)gDateTime;
127 	}
128 	
129 	/**
130 	 * Sets our main struct and passes it to the parent class
131 	 */
132 	public this (GDateTime* gDateTime)
133 	{
134 		this.gDateTime = gDateTime;
135 	}
136 	
137 	/**
138 	 * Creates a GDateTime corresponding to the given Unix time t
139 	 * Unix time is the number of seconds that have elapsed since 1970-01-01
140 	 * 00:00:00 UTC, regardless of the local time offset.
141 	 *
142 	 * This call can fail (returning NULL) if t represents a time outside
143 	 * of the supported range of GDateTime.
144 	 * You should release the return value by calling g_date_time_unref()
145 	 * when you are done with it.
146 	 * Since 2.26
147 	 *
148 	 * Params:
149 	 *     t   = the Unix time
150 	 *     utc = If true use utc else use the local timezone.
151 	 * Throws: ConstructionException GTK+ fails to create the object.
152 	 */
153 	public this (long t, bool utc = true)
154 	{
155 		// GDateTime * g_date_time_new_from_unix_local (gint64 t);
156 		GDateTime* p;
157 		
158 		if ( utc )
159 		{
160 			p = g_date_time_new_from_unix_utc(t);
161 		}
162 		else
163 		{
164 			p = g_date_time_new_from_unix_local(t);
165 		}
166 		
167 		if(p is null)
168 		{
169 			throw new ConstructionException("null returned by g_date_time_new_from_unix_local(t)");
170 		}
171 		this(cast(GDateTime*) p);
172 	}
173 	
174 	/**
175 	 * Creates a GDateTime corresponding to the given GTimeVal tv.
176 	 * The time contained in a GTimeVal is always stored in the form of
177 	 * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the
178 	 * local time offset.
179 	 *
180 	 * This call can fail (returning NULL) if tv represents a time outside
181 	 * of the supported range of GDateTime.
182 	 * You should release the return value by calling unref()
183 	 * when you are done with it.
184 	 * Since 2.26
185 	 *
186 	 * Params:
187 	 *     tv  = a GTimeVal
188 	 *     utc = If true use utc else use the local timezone.
189 	 * Throws: ConstructionException GTK+ fails to create the object.
190 	 */
191 	public this (ref GTimeVal tv, bool utc = true)
192 	{
193 		// GDateTime * g_date_time_new_from_timeval_local (const GTimeVal *tv);
194 		GDateTime* p;
195 		
196 		if ( utc )
197 		{
198 			p = g_date_time_new_from_timeval_utc(&tv);
199 		}
200 		else
201 		{
202 			p = g_date_time_new_from_timeval_local(&tv);
203 		}
204 		
205 		if(p is null)
206 		{
207 			throw new ConstructionException("null returned by g_date_time_new_from_timeval_local((tv is null) ? null : tv.getTimeValStruct())");
208 		}
209 		this(cast(GDateTime*) p);
210 	}
211 	
212 	~this ()
213 	{
214 		if ( Linker.isLoaded(LIBRARY.GLIB) && gDateTime !is null )
215 		{
216 			g_date_time_unref(gDateTime);
217 		}
218 	}
219 	
220 	override bool opEquals(Object rhs)
221 	{
222 		DateTime date = cast(DateTime)rhs;
223 		
224 		if ( date is null )
225 		return false;
226 		
227 		return equal(this, date) != 0;
228 	}
229 	
230 	override int opCmp(Object rhs)
231 	{
232 		DateTime date = cast(DateTime)rhs;
233 		
234 		if ( date is null )
235 		return int.min;
236 		
237 		return compare(this, date);
238 	}
239 	
240 	override hash_t toHash()
241 	{
242 		return hash(this);
243 	}
244 	
245 	/**
246 	 * Hashes datetime into a guint, suitable for use within GHashTable.
247 	 * Since 2.26
248 	 * Params:
249 	 * datetime = a GDateTime
250 	 * Returns: a guint containing the hash
251 	 */
252 	public static nothrow @trusted uint hash(DateTime datetime)
253 	{
254 		try
255 		{
256 			// guint g_date_time_hash (gconstpointer datetime);
257 			return g_date_time_hash((datetime is null) ? null : datetime.getDateTimeStruct());
258 		}
259 		catch(Exception e)
260 		{
261 			return 0;
262 		}
263 	}
264 	
265 	/**
266 	 */
267 	
268 	/**
269 	 * Atomically decrements the reference count of datetime by one.
270 	 * When the reference count reaches zero, the resources allocated by
271 	 * datetime are freed
272 	 * Since 2.26
273 	 */
274 	public void unref()
275 	{
276 		// void g_date_time_unref (GDateTime *datetime);
277 		g_date_time_unref(gDateTime);
278 	}
279 	
280 	/**
281 	 * Atomically increments the reference count of datetime by one.
282 	 * Since 2.26
283 	 * Returns: the GDateTime with the reference count increased
284 	 */
285 	public DateTime doref()
286 	{
287 		// GDateTime * g_date_time_ref (GDateTime *datetime);
288 		auto p = g_date_time_ref(gDateTime);
289 		
290 		if(p is null)
291 		{
292 			return null;
293 		}
294 		
295 		return new DateTime(cast(GDateTime*) p);
296 	}
297 	
298 	/**
299 	 * Creates a GDateTime corresponding to this exact instant in the given
300 	 * time zone tz. The time is as accurate as the system allows, to a
301 	 * maximum accuracy of 1 microsecond.
302 	 * This function will always succeed unless the system clock is set to
303 	 * truly insane values (or unless GLib is still being used after the
304 	 * year 9999).
305 	 * You should release the return value by calling g_date_time_unref()
306 	 * when you are done with it.
307 	 * Since 2.26
308 	 * Params:
309 	 * tz = a GTimeZone
310 	 * Throws: ConstructionException GTK+ fails to create the object.
311 	 */
312 	public this (TimeZone tz)
313 	{
314 		// GDateTime * g_date_time_new_now (GTimeZone *tz);
315 		auto p = g_date_time_new_now((tz is null) ? null : tz.getTimeZoneStruct());
316 		if(p is null)
317 		{
318 			throw new ConstructionException("null returned by g_date_time_new_now((tz is null) ? null : tz.getTimeZoneStruct())");
319 		}
320 		this(cast(GDateTime*) p);
321 	}
322 	
323 	/**
324 	 * Creates a new GDateTime corresponding to the given date and time in
325 	 * the time zone tz.
326 	 * The year must be between 1 and 9999, month between 1 and 12 and day
327 	 * between 1 and 28, 29, 30 or 31 depending on the month and the year.
328 	 * hour must be between 0 and 23 and minute must be between 0 and 59.
329 	 * seconds must be at least 0.0 and must be strictly less than 60.0.
330 	 * It will be rounded down to the nearest microsecond.
331 	 * If the given time is not representable in the given time zone (for
332 	 * example, 02:30 on March 14th 2010 in Toronto, due to daylight savings
333 	 * time) then the time will be rounded up to the nearest existing time
334 	 * (in this case, 03:00). If this matters to you then you should verify
335 	 * the return value for containing the same as the numbers you gave.
336 	 * In the case that the given time is ambiguous in the given time zone
337 	 * (for example, 01:30 on November 7th 2010 in Toronto, due to daylight
338 	 * Since 2.26
339 	 * Params:
340 	 * tz = a GTimeZone
341 	 * year = the year component of the date
342 	 * month = the month component of the date
343 	 * day = the day component of the date
344 	 * hour = the hour component of the date
345 	 * minute = the minute component of the date
346 	 * seconds = the number of seconds past the minute
347 	 * Throws: ConstructionException GTK+ fails to create the object.
348 	 */
349 	public this (TimeZone tz, int year, int month, int day, int hour, int minute, double seconds)
350 	{
351 		// GDateTime * g_date_time_new (GTimeZone *tz,  gint year,  gint month,  gint day,  gint hour,  gint minute,  gdouble seconds);
352 		auto p = g_date_time_new((tz is null) ? null : tz.getTimeZoneStruct(), year, month, day, hour, minute, seconds);
353 		if(p is null)
354 		{
355 			throw new ConstructionException("null returned by g_date_time_new((tz is null) ? null : tz.getTimeZoneStruct(), year, month, day, hour, minute, seconds)");
356 		}
357 		this(cast(GDateTime*) p);
358 	}
359 	
360 	/**
361 	 * Creates a copy of datetime and adds the specified timespan to the copy.
362 	 * Since 2.26
363 	 * Params:
364 	 * timespan = a GTimeSpan
365 	 * Returns: the newly created GDateTime which should be freed with g_date_time_unref().
366 	 */
367 	public DateTime add(GTimeSpan timespan)
368 	{
369 		// GDateTime * g_date_time_add (GDateTime *datetime,  GTimeSpan timespan);
370 		auto p = g_date_time_add(gDateTime, timespan);
371 		
372 		if(p is null)
373 		{
374 			return null;
375 		}
376 		
377 		return new DateTime(cast(GDateTime*) p);
378 	}
379 	
380 	/**
381 	 * Creates a copy of datetime and adds the specified number of years to the
382 	 * copy.
383 	 * Since 2.26
384 	 * Params:
385 	 * years = the number of years
386 	 * Returns: the newly created GDateTime which should be freed with g_date_time_unref().
387 	 */
388 	public DateTime addYears(int years)
389 	{
390 		// GDateTime * g_date_time_add_years (GDateTime *datetime,  gint years);
391 		auto p = g_date_time_add_years(gDateTime, years);
392 		
393 		if(p is null)
394 		{
395 			return null;
396 		}
397 		
398 		return new DateTime(cast(GDateTime*) p);
399 	}
400 	
401 	/**
402 	 * Creates a copy of datetime and adds the specified number of months to the
403 	 * copy.
404 	 * Since 2.26
405 	 * Params:
406 	 * months = the number of months
407 	 * Returns: the newly created GDateTime which should be freed with g_date_time_unref().
408 	 */
409 	public DateTime addMonths(int months)
410 	{
411 		// GDateTime * g_date_time_add_months (GDateTime *datetime,  gint months);
412 		auto p = g_date_time_add_months(gDateTime, months);
413 		
414 		if(p is null)
415 		{
416 			return null;
417 		}
418 		
419 		return new DateTime(cast(GDateTime*) p);
420 	}
421 	
422 	/**
423 	 * Creates a copy of datetime and adds the specified number of weeks to the
424 	 * copy.
425 	 * Since 2.26
426 	 * Params:
427 	 * weeks = the number of weeks
428 	 * Returns: the newly created GDateTime which should be freed with g_date_time_unref().
429 	 */
430 	public DateTime addWeeks(int weeks)
431 	{
432 		// GDateTime * g_date_time_add_weeks (GDateTime *datetime,  gint weeks);
433 		auto p = g_date_time_add_weeks(gDateTime, weeks);
434 		
435 		if(p is null)
436 		{
437 			return null;
438 		}
439 		
440 		return new DateTime(cast(GDateTime*) p);
441 	}
442 	
443 	/**
444 	 * Creates a copy of datetime and adds the specified number of days to the
445 	 * copy.
446 	 * Since 2.26
447 	 * Params:
448 	 * days = the number of days
449 	 * Returns: the newly created GDateTime which should be freed with g_date_time_unref().
450 	 */
451 	public DateTime addDays(int days)
452 	{
453 		// GDateTime * g_date_time_add_days (GDateTime *datetime,  gint days);
454 		auto p = g_date_time_add_days(gDateTime, days);
455 		
456 		if(p is null)
457 		{
458 			return null;
459 		}
460 		
461 		return new DateTime(cast(GDateTime*) p);
462 	}
463 	
464 	/**
465 	 * Creates a copy of datetime and adds the specified number of hours
466 	 * Since 2.26
467 	 * Params:
468 	 * hours = the number of hours to add
469 	 * Returns: the newly created GDateTime which should be freed with g_date_time_unref().
470 	 */
471 	public DateTime addHours(int hours)
472 	{
473 		// GDateTime * g_date_time_add_hours (GDateTime *datetime,  gint hours);
474 		auto p = g_date_time_add_hours(gDateTime, hours);
475 		
476 		if(p is null)
477 		{
478 			return null;
479 		}
480 		
481 		return new DateTime(cast(GDateTime*) p);
482 	}
483 	
484 	/**
485 	 * Creates a copy of datetime adding the specified number of minutes.
486 	 * Since 2.26
487 	 * Params:
488 	 * minutes = the number of minutes to add
489 	 * Returns: the newly created GDateTime which should be freed with g_date_time_unref().
490 	 */
491 	public DateTime addMinutes(int minutes)
492 	{
493 		// GDateTime * g_date_time_add_minutes (GDateTime *datetime,  gint minutes);
494 		auto p = g_date_time_add_minutes(gDateTime, minutes);
495 		
496 		if(p is null)
497 		{
498 			return null;
499 		}
500 		
501 		return new DateTime(cast(GDateTime*) p);
502 	}
503 	
504 	/**
505 	 * Creates a copy of datetime and adds the specified number of seconds.
506 	 * Since 2.26
507 	 * Params:
508 	 * seconds = the number of seconds to add
509 	 * Returns: the newly created GDateTime which should be freed with g_date_time_unref().
510 	 */
511 	public DateTime addSeconds(double seconds)
512 	{
513 		// GDateTime * g_date_time_add_seconds (GDateTime *datetime,  gdouble seconds);
514 		auto p = g_date_time_add_seconds(gDateTime, seconds);
515 		
516 		if(p is null)
517 		{
518 			return null;
519 		}
520 		
521 		return new DateTime(cast(GDateTime*) p);
522 	}
523 	
524 	/**
525 	 * Creates a new GDateTime adding the specified values to the current date and
526 	 * time in datetime.
527 	 * Since 2.26
528 	 * Params:
529 	 * years = the number of years to add
530 	 * months = the number of months to add
531 	 * days = the number of days to add
532 	 * hours = the number of hours to add
533 	 * minutes = the number of minutes to add
534 	 * seconds = the number of seconds to add
535 	 * Returns: the newly created GDateTime that should be freed with g_date_time_unref().
536 	 */
537 	public DateTime addFull(int years, int months, int days, int hours, int minutes, double seconds)
538 	{
539 		// GDateTime * g_date_time_add_full (GDateTime *datetime,  gint years,  gint months,  gint days,  gint hours,  gint minutes,  gdouble seconds);
540 		auto p = g_date_time_add_full(gDateTime, years, months, days, hours, minutes, seconds);
541 		
542 		if(p is null)
543 		{
544 			return null;
545 		}
546 		
547 		return new DateTime(cast(GDateTime*) p);
548 	}
549 	
550 	/**
551 	 * A comparison function for GDateTimes that is suitable
552 	 * as a GCompareFunc. Both GDateTimes must be non-NULL.
553 	 * Since 2.26
554 	 * Params:
555 	 * dt1 = first GDateTime to compare
556 	 * dt2 = second GDateTime to compare
557 	 * Returns: -1, 0 or 1 if dt1 is less than, equal to or greater than dt2.
558 	 */
559 	public static int compare(DateTime dt1, DateTime dt2)
560 	{
561 		// gint g_date_time_compare (gconstpointer dt1,  gconstpointer dt2);
562 		return g_date_time_compare((dt1 is null) ? null : dt1.getDateTimeStruct(), (dt2 is null) ? null : dt2.getDateTimeStruct());
563 	}
564 	
565 	/**
566 	 * Calculates the difference in time between end and begin. The
567 	 * Since 2.26
568 	 * Params:
569 	 * begin = a GDateTime
570 	 * Returns: the difference between the two GDateTime, as a time span expressed in microseconds.
571 	 */
572 	public GTimeSpan difference(DateTime begin)
573 	{
574 		// GTimeSpan g_date_time_difference (GDateTime *end,  GDateTime *begin);
575 		return g_date_time_difference(gDateTime, (begin is null) ? null : begin.getDateTimeStruct());
576 	}
577 	
578 	/**
579 	 * Checks to see if dt1 and dt2 are equal.
580 	 * Equal here means that they represent the same moment after converting
581 	 * them to the same time zone.
582 	 * Since 2.26
583 	 * Params:
584 	 * dt1 = a GDateTime
585 	 * dt2 = a GDateTime
586 	 * Returns: TRUE if dt1 and dt2 are equal
587 	 */
588 	public static int equal(DateTime dt1, DateTime dt2)
589 	{
590 		// gboolean g_date_time_equal (gconstpointer dt1,  gconstpointer dt2);
591 		return g_date_time_equal((dt1 is null) ? null : dt1.getDateTimeStruct(), (dt2 is null) ? null : dt2.getDateTimeStruct());
592 	}
593 	
594 	/**
595 	 * Retrieves the Gregorian day, month, and year of a given GDateTime.
596 	 * Since 2.26
597 	 * Params:
598 	 * year = the return location for the gregorian year, or NULL. [out][allow-none]
599 	 * month = the return location for the month of the year, or NULL. [out][allow-none]
600 	 * day = the return location for the day of the month, or NULL. [out][allow-none]
601 	 */
602 	public void getYmd(out int year, out int month, out int day)
603 	{
604 		// void g_date_time_get_ymd (GDateTime *datetime,  gint *year,  gint *month,  gint *day);
605 		g_date_time_get_ymd(gDateTime, &year, &month, &day);
606 	}
607 	
608 	/**
609 	 * Retrieves the year represented by datetime in the Gregorian calendar.
610 	 * Since 2.26
611 	 * Returns: the year represented by datetime
612 	 */
613 	public int getYear()
614 	{
615 		// gint g_date_time_get_year (GDateTime *datetime);
616 		return g_date_time_get_year(gDateTime);
617 	}
618 	
619 	/**
620 	 * Retrieves the month of the year represented by datetime in the Gregorian
621 	 * calendar.
622 	 * Since 2.26
623 	 * Returns: the month represented by datetime
624 	 */
625 	public int getMonth()
626 	{
627 		// gint g_date_time_get_month (GDateTime *datetime);
628 		return g_date_time_get_month(gDateTime);
629 	}
630 	
631 	/**
632 	 * Retrieves the day of the month represented by datetime in the gregorian
633 	 * calendar.
634 	 * Since 2.26
635 	 * Returns: the day of the month
636 	 */
637 	public int getDayOfMonth()
638 	{
639 		// gint g_date_time_get_day_of_month (GDateTime *datetime);
640 		return g_date_time_get_day_of_month(gDateTime);
641 	}
642 	
643 	/**
644 	 * Returns the ISO 8601 week-numbering year in which the week containing
645 	 * datetime falls.
646 	 * This function, taken together with g_date_time_get_week_of_year() and
647 	 * g_date_time_get_day_of_week() can be used to determine the full ISO
648 	 * week date on which datetime falls.
649 	 * This is usually equal to the normal Gregorian year (as returned by
650 	 * Since 2.26
651 	 * Returns: the ISO 8601 week-numbering year for datetime
652 	 */
653 	public int getWeekNumberingYear()
654 	{
655 		// gint g_date_time_get_week_numbering_year (GDateTime *datetime);
656 		return g_date_time_get_week_numbering_year(gDateTime);
657 	}
658 	
659 	/**
660 	 * Returns the ISO 8601 week number for the week containing datetime.
661 	 * The ISO 8601 week number is the same for every day of the week (from
662 	 * Moday through Sunday). That can produce some unusual results
663 	 * (described below).
664 	 * The first week of the year is week 1. This is the week that contains
665 	 * the first Thursday of the year. Equivalently, this is the first week
666 	 * that has more than 4 of its days falling within the calendar year.
667 	 * The value 0 is never returned by this function. Days contained
668 	 * within a year but occurring before the first ISO 8601 week of that
669 	 * year are considered as being contained in the last week of the
670 	 * previous year. Similarly, the final days of a calendar year may be
671 	 * considered as being part of the first ISO 8601 week of the next year
672 	 * if 4 or more days of that week are contained within the new year.
673 	 * Since 2.26
674 	 * Returns: the ISO 8601 week number for datetime.
675 	 */
676 	public int getWeekOfYear()
677 	{
678 		// gint g_date_time_get_week_of_year (GDateTime *datetime);
679 		return g_date_time_get_week_of_year(gDateTime);
680 	}
681 	
682 	/**
683 	 * Retrieves the ISO 8601 day of the week on which datetime falls (1 is
684 	 * Monday, 2 is Tuesday... 7 is Sunday).
685 	 * Since 2.26
686 	 * Returns: the day of the week
687 	 */
688 	public int getDayOfWeek()
689 	{
690 		// gint g_date_time_get_day_of_week (GDateTime *datetime);
691 		return g_date_time_get_day_of_week(gDateTime);
692 	}
693 	
694 	/**
695 	 * Retrieves the day of the year represented by datetime in the Gregorian
696 	 * calendar.
697 	 * Since 2.26
698 	 * Returns: the day of the year
699 	 */
700 	public int getDayOfYear()
701 	{
702 		// gint g_date_time_get_day_of_year (GDateTime *datetime);
703 		return g_date_time_get_day_of_year(gDateTime);
704 	}
705 	
706 	/**
707 	 * Retrieves the hour of the day represented by datetime
708 	 * Since 2.26
709 	 * Returns: the hour of the day
710 	 */
711 	public int getHour()
712 	{
713 		// gint g_date_time_get_hour (GDateTime *datetime);
714 		return g_date_time_get_hour(gDateTime);
715 	}
716 	
717 	/**
718 	 * Retrieves the minute of the hour represented by datetime
719 	 * Since 2.26
720 	 * Returns: the minute of the hour
721 	 */
722 	public int getMinute()
723 	{
724 		// gint g_date_time_get_minute (GDateTime *datetime);
725 		return g_date_time_get_minute(gDateTime);
726 	}
727 	
728 	/**
729 	 * Retrieves the second of the minute represented by datetime
730 	 * Since 2.26
731 	 * Returns: the second represented by datetime
732 	 */
733 	public int getSecond()
734 	{
735 		// gint g_date_time_get_second (GDateTime *datetime);
736 		return g_date_time_get_second(gDateTime);
737 	}
738 	
739 	/**
740 	 * Retrieves the microsecond of the date represented by datetime
741 	 * Since 2.26
742 	 * Returns: the microsecond of the second
743 	 */
744 	public int getMicrosecond()
745 	{
746 		// gint g_date_time_get_microsecond (GDateTime *datetime);
747 		return g_date_time_get_microsecond(gDateTime);
748 	}
749 	
750 	/**
751 	 * Retrieves the number of seconds since the start of the last minute,
752 	 * including the fractional part.
753 	 * Since 2.26
754 	 * Returns: the number of seconds
755 	 */
756 	public double getSeconds()
757 	{
758 		// gdouble g_date_time_get_seconds (GDateTime *datetime);
759 		return g_date_time_get_seconds(gDateTime);
760 	}
761 	
762 	/**
763 	 * Gives the Unix time corresponding to datetime, rounding down to the
764 	 * nearest second.
765 	 * Unix time is the number of seconds that have elapsed since 1970-01-01
766 	 * 00:00:00 UTC, regardless of the time zone associated with datetime.
767 	 * Since 2.26
768 	 * Returns: the Unix time corresponding to datetime
769 	 */
770 	public long toUnix()
771 	{
772 		// gint64 g_date_time_to_unix (GDateTime *datetime);
773 		return g_date_time_to_unix(gDateTime);
774 	}
775 	
776 	/**
777 	 * Stores the instant in time that datetime represents into tv.
778 	 * The time contained in a GTimeVal is always stored in the form of
779 	 * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time
780 	 * zone associated with datetime.
781 	 * On systems where 'long' is 32bit (ie: all 32bit systems and all
782 	 * Windows systems), a GTimeVal is incapable of storing the entire
783 	 * range of values that GDateTime is capable of expressing. On those
784 	 * systems, this function returns FALSE to indicate that the time is
785 	 * out of range.
786 	 * On systems where 'long' is 64bit, this function never fails.
787 	 * Since 2.26
788 	 * Params:
789 	 * tv = a GTimeVal to modify
790 	 * Returns: TRUE if successful, else FALSE
791 	 */
792 	public int toTimeval(out GTimeVal tv)
793 	{
794 		// gboolean g_date_time_to_timeval (GDateTime *datetime,  GTimeVal *tv);
795 		return g_date_time_to_timeval(gDateTime, &tv);
796 	}
797 	
798 	/**
799 	 * Determines the offset to UTC in effect at the time and in the time
800 	 * zone of datetime.
801 	 * The offset is the number of microseconds that you add to UTC time to
802 	 * arrive at local time for the time zone (ie: negative numbers for time
803 	 * zones west of GMT, positive numbers for east).
804 	 * If datetime represents UTC time, then the offset is always zero.
805 	 * Since 2.26
806 	 * Returns: the number of microseconds that should be added to UTC to get the local time
807 	 */
808 	public GTimeSpan getUtcOffset()
809 	{
810 		// GTimeSpan g_date_time_get_utc_offset (GDateTime *datetime);
811 		return g_date_time_get_utc_offset(gDateTime);
812 	}
813 	
814 	/**
815 	 * Determines the time zone abbreviation to be used at the time and in
816 	 * the time zone of datetime.
817 	 * For example, in Toronto this is currently "EST" during the winter
818 	 * months and "EDT" during the summer months when daylight savings
819 	 * time is in effect.
820 	 * Since 2.26
821 	 * Returns: the time zone abbreviation. The returned string is owned by the GDateTime and it should not be modified or freed. [transfer none]
822 	 */
823 	public string getTimezoneAbbreviation()
824 	{
825 		// const gchar * g_date_time_get_timezone_abbreviation  (GDateTime *datetime);
826 		return Str.toString(g_date_time_get_timezone_abbreviation(gDateTime));
827 	}
828 	
829 	/**
830 	 * Determines if daylight savings time is in effect at the time and in
831 	 * the time zone of datetime.
832 	 * Since 2.26
833 	 * Returns: TRUE if daylight savings time is in effect
834 	 */
835 	public int isDaylightSavings()
836 	{
837 		// gboolean g_date_time_is_daylight_savings (GDateTime *datetime);
838 		return g_date_time_is_daylight_savings(gDateTime);
839 	}
840 	
841 	/**
842 	 * Create a new GDateTime corresponding to the same instant in time as
843 	 * datetime, but in the time zone tz.
844 	 * This call can fail in the case that the time goes out of bounds. For
845 	 * example, converting 0001-01-01 00:00:00 UTC to a time zone west of
846 	 * Greenwich will fail (due to the year 0 being out of range).
847 	 * You should release the return value by calling g_date_time_unref()
848 	 * when you are done with it.
849 	 * Since 2.26
850 	 * Params:
851 	 * tz = the new GTimeZone
852 	 * Returns: a new GDateTime, or NULL
853 	 */
854 	public DateTime toTimezone(TimeZone tz)
855 	{
856 		// GDateTime * g_date_time_to_timezone (GDateTime *datetime,  GTimeZone *tz);
857 		auto p = g_date_time_to_timezone(gDateTime, (tz is null) ? null : tz.getTimeZoneStruct());
858 		
859 		if(p is null)
860 		{
861 			return null;
862 		}
863 		
864 		return new DateTime(cast(GDateTime*) p);
865 	}
866 	
867 	/**
868 	 * Creates a new GDateTime corresponding to the same instant in time as
869 	 * datetime, but in the local time zone.
870 	 * This call is equivalent to calling g_date_time_to_timezone() with the
871 	 * time zone returned by g_time_zone_new_local().
872 	 * Since 2.26
873 	 * Returns: the newly created GDateTime
874 	 */
875 	public DateTime toLocal()
876 	{
877 		// GDateTime * g_date_time_to_local (GDateTime *datetime);
878 		auto p = g_date_time_to_local(gDateTime);
879 		
880 		if(p is null)
881 		{
882 			return null;
883 		}
884 		
885 		return new DateTime(cast(GDateTime*) p);
886 	}
887 	
888 	/**
889 	 * Creates a new GDateTime corresponding to the same instant in time as
890 	 * datetime, but in UTC.
891 	 * This call is equivalent to calling g_date_time_to_timezone() with the
892 	 * time zone returned by g_time_zone_new_utc().
893 	 * Since 2.26
894 	 * Returns: the newly created GDateTime
895 	 */
896 	public DateTime toUtc()
897 	{
898 		// GDateTime * g_date_time_to_utc (GDateTime *datetime);
899 		auto p = g_date_time_to_utc(gDateTime);
900 		
901 		if(p is null)
902 		{
903 			return null;
904 		}
905 		
906 		return new DateTime(cast(GDateTime*) p);
907 	}
908 	
909 	/**
910 	 * Creates a newly allocated string representing the requested format.
911 	 * The format strings understood by this function are a subset of the
912 	 * strftime() format language as specified by C99. The %D, %U and %W
913 	 * conversions are not supported, nor is the 'E' modifier. The GNU
914 	 * extensions %k, %l, %s and %P are supported, however, as are the
915 	 * '0', '_' and '-' modifiers.
916 	 * In contrast to strftime(), this function always produces a UTF-8
917 	 * string, regardless of the current locale. Note that the rendering of
918 	 * many formats is locale-dependent and may not match the strftime()
919 	 * output exactly.
920 	 * Since 2.26
921 	 * Params:
922 	 * format = a valid UTF-8 string, containing the format for the
923 	 * GDateTime
924 	 * Returns: a newly allocated string formatted to the requested format or NULL in the case that there was an error. The string should be freed with g_free().
925 	 */
926 	public string format(string format)
927 	{
928 		// gchar * g_date_time_format (GDateTime *datetime,  const gchar *format);
929 		return Str.toString(g_date_time_format(gDateTime, Str.toStringz(format)));
930 	}
931 }