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