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