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 module glib.DateTime;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import glib.TimeVal;
30 private import glib.TimeZone;
31 private import glib.c.functions;
32 public  import glib.c.types;
33 public  import gtkc.glibtypes;
34 private import gtkd.Loader;
35 
36 
37 /**
38  * `GDateTime` is an opaque structure whose members
39  * cannot be accessed directly.
40  *
41  * Since: 2.26
42  */
43 public class DateTime
44 {
45 	/** the main Gtk struct */
46 	protected GDateTime* gDateTime;
47 	protected bool ownedRef;
48 
49 	/** Get the main Gtk struct */
50 	public GDateTime* getDateTimeStruct(bool transferOwnership = false)
51 	{
52 		if (transferOwnership)
53 			ownedRef = false;
54 		return gDateTime;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected void* getStruct()
59 	{
60 		return cast(void*)gDateTime;
61 	}
62 
63 	/**
64 	 * Sets our main struct and passes it to the parent class.
65 	 */
66 	public this (GDateTime* gDateTime, bool ownedRef = false)
67 	{
68 		this.gDateTime = gDateTime;
69 		this.ownedRef = ownedRef;
70 	}
71 
72 	~this ()
73 	{
74 		if ( Linker.isLoaded(LIBRARY_GLIB) && ownedRef )
75 			g_date_time_unref(gDateTime);
76 	}
77 
78 	/**
79 	 * Creates a DateTime corresponding to the given Unix time t
80 	 * Unix time is the number of seconds that have elapsed since 1970-01-01
81 	 * 00:00:00 UTC, regardless of the local time offset.
82 	 *
83 	 * This call can fail (ConstructionException) if t represents a time outside
84 	 * of the supported range of GDateTime.
85 	 * You should release the return value by calling unref()
86 	 * when you are done with it
87 	 *
88 	 * Params:
89 	 *     t   = the Unix time
90 	 *     utc = If true use utc else use the local timezone.
91 	 *
92 	 * Throws: ConstructionException GTK+ fails to create the object.
93 	 *
94 	 * Since: 2.26
95 	 */
96 	public this (long t, bool utc = true)
97 	{
98 		GDateTime* p;
99 
100 		if ( utc )
101 		{
102 			p = g_date_time_new_from_unix_utc(t);
103 		}
104 		else
105 		{
106 			p = g_date_time_new_from_unix_local(t);
107 		}
108 
109 		if(p is null)
110 		{
111 			throw new ConstructionException("null returned by g_date_time_new_from_unix_local(t)");
112 		}
113 		this(cast(GDateTime*) p);
114 	}
115 
116 	/**
117 	 * Creates a DateTime corresponding to the given TimeVal tv.
118 	 * The time contained in a TimeVal is always stored in the form of
119 	 * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the
120 	 * local time offset.
121 	 *
122 	 * This call can fail (ConstructionException) if tv represents a time outside
123 	 * of the supported range of DateTime.
124 	 * You should release the return value by calling unref()
125 	 * when you are done with it.
126 	 *
127 	 * Params:
128 	 *     tv  = a GTimeVal
129 	 *     utc = If true use utc else use the local timezone.
130 	 *
131 	 * Throws: ConstructionException GTK+ fails to create the object.
132 	 *
133 	 * Since: 2.26
134 	 */
135 	public this (ref GTimeVal tv, bool utc = true)
136 	{
137 		GDateTime* p;
138 
139 		if ( utc )
140 		{
141 			p = g_date_time_new_from_timeval_utc(&tv);
142 		}
143 		else
144 		{
145 			p = g_date_time_new_from_timeval_local(&tv);
146 		}
147 
148 		if(p is null)
149 		{
150 			throw new ConstructionException("null returned by g_date_time_new_from_timeval_local((tv is null) ? null : tv.getTimeValStruct())");
151 		}
152 		this(cast(GDateTime*) p);
153 	}
154 
155 	/** */
156 	override bool opEquals(Object rhs)
157 	{
158 		DateTime date = cast(DateTime)rhs;
159 
160 		if ( date is null )
161 			return false;
162 
163 		return equal(this, date) != 0;
164 	}
165 
166 	/** */
167 	override int opCmp(Object rhs)
168 	{
169 		DateTime date = cast(DateTime)rhs;
170 
171 		if ( date is null )
172 			return int.min;
173 
174 		return compare(this, date);
175 	}
176 
177 	/** */
178 	override nothrow @trusted hash_t toHash()
179 	{
180 		return hash();
181 	}
182 
183 	/**
184 	 * Hashes datetime into a guint, suitable for use within GHashTable.
185 	 * Since 2.26
186 	 * Params:
187 	 * datetime = a GDateTime
188 	 * Returns: a guint containing the hash
189 	 */
190 	public nothrow @trusted uint hash()
191 	{
192 		try
193 		{
194 			return g_date_time_hash(gDateTime);
195 		}
196 		catch(Exception e)
197 		{
198 			return 0;
199 		}
200 	}
201 
202 	/**
203 	 */
204 
205 	/**
206 	 * Creates a new #GDateTime corresponding to the given date and time in
207 	 * the time zone @tz.
208 	 *
209 	 * The @year must be between 1 and 9999, @month between 1 and 12 and @day
210 	 * between 1 and 28, 29, 30 or 31 depending on the month and the year.
211 	 *
212 	 * @hour must be between 0 and 23 and @minute must be between 0 and 59.
213 	 *
214 	 * @seconds must be at least 0.0 and must be strictly less than 60.0.
215 	 * It will be rounded down to the nearest microsecond.
216 	 *
217 	 * If the given time is not representable in the given time zone (for
218 	 * example, 02:30 on March 14th 2010 in Toronto, due to daylight savings
219 	 * time) then the time will be rounded up to the nearest existing time
220 	 * (in this case, 03:00).  If this matters to you then you should verify
221 	 * the return value for containing the same as the numbers you gave.
222 	 *
223 	 * In the case that the given time is ambiguous in the given time zone
224 	 * (for example, 01:30 on November 7th 2010 in Toronto, due to daylight
225 	 * savings time) then the time falling within standard (ie:
226 	 * non-daylight) time is taken.
227 	 *
228 	 * It not considered a programmer error for the values to this function
229 	 * to be out of range, but in the case that they are, the function will
230 	 * return %NULL.
231 	 *
232 	 * You should release the return value by calling g_date_time_unref()
233 	 * when you are done with it.
234 	 *
235 	 * Params:
236 	 *     tz = a #GTimeZone
237 	 *     year = the year component of the date
238 	 *     month = the month component of the date
239 	 *     day = the day component of the date
240 	 *     hour = the hour component of the date
241 	 *     minute = the minute component of the date
242 	 *     seconds = the number of seconds past the minute
243 	 *
244 	 * Returns: a new #GDateTime, or %NULL
245 	 *
246 	 * Since: 2.26
247 	 *
248 	 * Throws: ConstructionException GTK+ fails to create the object.
249 	 */
250 	public this(TimeZone tz, int year, int month, int day, int hour, int minute, double seconds)
251 	{
252 		auto p = g_date_time_new((tz is null) ? null : tz.getTimeZoneStruct(), year, month, day, hour, minute, seconds);
253 
254 		if(p is null)
255 		{
256 			throw new ConstructionException("null returned by new");
257 		}
258 
259 		this(cast(GDateTime*) p);
260 	}
261 
262 	/**
263 	 * Creates a #GDateTime corresponding to this exact instant in the given
264 	 * time zone @tz.  The time is as accurate as the system allows, to a
265 	 * maximum accuracy of 1 microsecond.
266 	 *
267 	 * This function will always succeed unless the system clock is set to
268 	 * truly insane values (or unless GLib is still being used after the
269 	 * year 9999).
270 	 *
271 	 * You should release the return value by calling g_date_time_unref()
272 	 * when you are done with it.
273 	 *
274 	 * Params:
275 	 *     tz = a #GTimeZone
276 	 *
277 	 * Returns: a new #GDateTime, or %NULL
278 	 *
279 	 * Since: 2.26
280 	 *
281 	 * Throws: ConstructionException GTK+ fails to create the object.
282 	 */
283 	public this(TimeZone tz)
284 	{
285 		auto p = g_date_time_new_now((tz is null) ? null : tz.getTimeZoneStruct());
286 
287 		if(p is null)
288 		{
289 			throw new ConstructionException("null returned by new_now");
290 		}
291 
292 		this(cast(GDateTime*) p);
293 	}
294 
295 	/**
296 	 * Creates a copy of @datetime and adds the specified timespan to the copy.
297 	 *
298 	 * Params:
299 	 *     timespan = a #GTimeSpan
300 	 *
301 	 * Returns: the newly created #GDateTime which should be freed with
302 	 *     g_date_time_unref().
303 	 *
304 	 * Since: 2.26
305 	 */
306 	public DateTime add(GTimeSpan timespan)
307 	{
308 		auto p = g_date_time_add(gDateTime, timespan);
309 
310 		if(p is null)
311 		{
312 			return null;
313 		}
314 
315 		return new DateTime(cast(GDateTime*) p, true);
316 	}
317 
318 	/**
319 	 * Creates a copy of @datetime and adds the specified number of days to the
320 	 * copy. Add negative values to subtract days.
321 	 *
322 	 * Params:
323 	 *     days = the number of days
324 	 *
325 	 * Returns: the newly created #GDateTime which should be freed with
326 	 *     g_date_time_unref().
327 	 *
328 	 * Since: 2.26
329 	 */
330 	public DateTime addDays(int days)
331 	{
332 		auto p = g_date_time_add_days(gDateTime, days);
333 
334 		if(p is null)
335 		{
336 			return null;
337 		}
338 
339 		return new DateTime(cast(GDateTime*) p, true);
340 	}
341 
342 	/**
343 	 * Creates a new #GDateTime adding the specified values to the current date and
344 	 * time in @datetime. Add negative values to subtract.
345 	 *
346 	 * Params:
347 	 *     years = the number of years to add
348 	 *     months = the number of months to add
349 	 *     days = the number of days to add
350 	 *     hours = the number of hours to add
351 	 *     minutes = the number of minutes to add
352 	 *     seconds = the number of seconds to add
353 	 *
354 	 * Returns: the newly created #GDateTime that should be freed with
355 	 *     g_date_time_unref().
356 	 *
357 	 * Since: 2.26
358 	 */
359 	public DateTime addFull(int years, int months, int days, int hours, int minutes, double seconds)
360 	{
361 		auto p = g_date_time_add_full(gDateTime, years, months, days, hours, minutes, seconds);
362 
363 		if(p is null)
364 		{
365 			return null;
366 		}
367 
368 		return new DateTime(cast(GDateTime*) p, true);
369 	}
370 
371 	/**
372 	 * Creates a copy of @datetime and adds the specified number of hours.
373 	 * Add negative values to subtract hours.
374 	 *
375 	 * Params:
376 	 *     hours = the number of hours to add
377 	 *
378 	 * Returns: the newly created #GDateTime which should be freed with
379 	 *     g_date_time_unref().
380 	 *
381 	 * Since: 2.26
382 	 */
383 	public DateTime addHours(int hours)
384 	{
385 		auto p = g_date_time_add_hours(gDateTime, hours);
386 
387 		if(p is null)
388 		{
389 			return null;
390 		}
391 
392 		return new DateTime(cast(GDateTime*) p, true);
393 	}
394 
395 	/**
396 	 * Creates a copy of @datetime adding the specified number of minutes.
397 	 * Add negative values to subtract minutes.
398 	 *
399 	 * Params:
400 	 *     minutes = the number of minutes to add
401 	 *
402 	 * Returns: the newly created #GDateTime which should be freed with
403 	 *     g_date_time_unref().
404 	 *
405 	 * Since: 2.26
406 	 */
407 	public DateTime addMinutes(int minutes)
408 	{
409 		auto p = g_date_time_add_minutes(gDateTime, minutes);
410 
411 		if(p is null)
412 		{
413 			return null;
414 		}
415 
416 		return new DateTime(cast(GDateTime*) p, true);
417 	}
418 
419 	/**
420 	 * Creates a copy of @datetime and adds the specified number of months to the
421 	 * copy. Add negative values to subtract months.
422 	 *
423 	 * Params:
424 	 *     months = the number of months
425 	 *
426 	 * Returns: the newly created #GDateTime which should be freed with
427 	 *     g_date_time_unref().
428 	 *
429 	 * Since: 2.26
430 	 */
431 	public DateTime addMonths(int months)
432 	{
433 		auto p = g_date_time_add_months(gDateTime, months);
434 
435 		if(p is null)
436 		{
437 			return null;
438 		}
439 
440 		return new DateTime(cast(GDateTime*) p, true);
441 	}
442 
443 	/**
444 	 * Creates a copy of @datetime and adds the specified number of seconds.
445 	 * Add negative values to subtract seconds.
446 	 *
447 	 * Params:
448 	 *     seconds = the number of seconds to add
449 	 *
450 	 * Returns: the newly created #GDateTime which should be freed with
451 	 *     g_date_time_unref().
452 	 *
453 	 * Since: 2.26
454 	 */
455 	public DateTime addSeconds(double seconds)
456 	{
457 		auto p = g_date_time_add_seconds(gDateTime, seconds);
458 
459 		if(p is null)
460 		{
461 			return null;
462 		}
463 
464 		return new DateTime(cast(GDateTime*) p, true);
465 	}
466 
467 	/**
468 	 * Creates a copy of @datetime and adds the specified number of weeks to the
469 	 * copy. Add negative values to subtract weeks.
470 	 *
471 	 * Params:
472 	 *     weeks = the number of weeks
473 	 *
474 	 * Returns: the newly created #GDateTime which should be freed with
475 	 *     g_date_time_unref().
476 	 *
477 	 * Since: 2.26
478 	 */
479 	public DateTime addWeeks(int weeks)
480 	{
481 		auto p = g_date_time_add_weeks(gDateTime, weeks);
482 
483 		if(p is null)
484 		{
485 			return null;
486 		}
487 
488 		return new DateTime(cast(GDateTime*) p, true);
489 	}
490 
491 	/**
492 	 * Creates a copy of @datetime and adds the specified number of years to the
493 	 * copy. Add negative values to subtract years.
494 	 *
495 	 * Params:
496 	 *     years = the number of years
497 	 *
498 	 * Returns: the newly created #GDateTime which should be freed with
499 	 *     g_date_time_unref().
500 	 *
501 	 * Since: 2.26
502 	 */
503 	public DateTime addYears(int years)
504 	{
505 		auto p = g_date_time_add_years(gDateTime, years);
506 
507 		if(p is null)
508 		{
509 			return null;
510 		}
511 
512 		return new DateTime(cast(GDateTime*) p, true);
513 	}
514 
515 	/**
516 	 * Calculates the difference in time between @end and @begin.  The
517 	 * #GTimeSpan that is returned is effectively @end - @begin (ie:
518 	 * positive if the first parameter is larger).
519 	 *
520 	 * Params:
521 	 *     begin = a #GDateTime
522 	 *
523 	 * Returns: the difference between the two #GDateTime, as a time
524 	 *     span expressed in microseconds.
525 	 *
526 	 * Since: 2.26
527 	 */
528 	public GTimeSpan difference(DateTime begin)
529 	{
530 		return g_date_time_difference(gDateTime, (begin is null) ? null : begin.getDateTimeStruct());
531 	}
532 
533 	/**
534 	 * Creates a newly allocated string representing the requested @format.
535 	 *
536 	 * The format strings understood by this function are a subset of the
537 	 * strftime() format language as specified by C99.  The \%D, \%U and \%W
538 	 * conversions are not supported, nor is the 'E' modifier.  The GNU
539 	 * extensions \%k, \%l, \%s and \%P are supported, however, as are the
540 	 * '0', '_' and '-' modifiers.
541 	 *
542 	 * In contrast to strftime(), this function always produces a UTF-8
543 	 * string, regardless of the current locale.  Note that the rendering of
544 	 * many formats is locale-dependent and may not match the strftime()
545 	 * output exactly.
546 	 *
547 	 * The following format specifiers are supported:
548 	 *
549 	 * - \%a: the abbreviated weekday name according to the current locale
550 	 * - \%A: the full weekday name according to the current locale
551 	 * - \%b: the abbreviated month name according to the current locale
552 	 * - \%B: the full month name according to the current locale
553 	 * - \%c: the preferred date and time representation for the current locale
554 	 * - \%C: the century number (year/100) as a 2-digit integer (00-99)
555 	 * - \%d: the day of the month as a decimal number (range 01 to 31)
556 	 * - \%e: the day of the month as a decimal number (range  1 to 31)
557 	 * - \%F: equivalent to `%Y-%m-%d` (the ISO 8601 date format)
558 	 * - \%g: the last two digits of the ISO 8601 week-based year as a
559 	 * decimal number (00-99). This works well with \%V and \%u.
560 	 * - \%G: the ISO 8601 week-based year as a decimal number. This works
561 	 * well with \%V and \%u.
562 	 * - \%h: equivalent to \%b
563 	 * - \%H: the hour as a decimal number using a 24-hour clock (range 00 to 23)
564 	 * - \%I: the hour as a decimal number using a 12-hour clock (range 01 to 12)
565 	 * - \%j: the day of the year as a decimal number (range 001 to 366)
566 	 * - \%k: the hour (24-hour clock) as a decimal number (range 0 to 23);
567 	 * single digits are preceded by a blank
568 	 * - \%l: the hour (12-hour clock) as a decimal number (range 1 to 12);
569 	 * single digits are preceded by a blank
570 	 * - \%m: the month as a decimal number (range 01 to 12)
571 	 * - \%M: the minute as a decimal number (range 00 to 59)
572 	 * - \%p: either "AM" or "PM" according to the given time value, or the
573 	 * corresponding  strings for the current locale.  Noon is treated as
574 	 * "PM" and midnight as "AM".
575 	 * - \%P: like \%p but lowercase: "am" or "pm" or a corresponding string for
576 	 * the current locale
577 	 * - \%r: the time in a.m. or p.m. notation
578 	 * - \%R: the time in 24-hour notation (\%H:\%M)
579 	 * - \%s: the number of seconds since the Epoch, that is, since 1970-01-01
580 	 * 00:00:00 UTC
581 	 * - \%S: the second as a decimal number (range 00 to 60)
582 	 * - \%t: a tab character
583 	 * - \%T: the time in 24-hour notation with seconds (\%H:\%M:\%S)
584 	 * - \%u: the ISO 8601 standard day of the week as a decimal, range 1 to 7,
585 	 * Monday being 1. This works well with \%G and \%V.
586 	 * - \%V: the ISO 8601 standard week number of the current year as a decimal
587 	 * number, range 01 to 53, where week 1 is the first week that has at
588 	 * least 4 days in the new year. See g_date_time_get_week_of_year().
589 	 * This works well with \%G and \%u.
590 	 * - \%w: the day of the week as a decimal, range 0 to 6, Sunday being 0.
591 	 * This is not the ISO 8601 standard format -- use \%u instead.
592 	 * - \%x: the preferred date representation for the current locale without
593 	 * the time
594 	 * - \%X: the preferred time representation for the current locale without
595 	 * the date
596 	 * - \%y: the year as a decimal number without the century
597 	 * - \%Y: the year as a decimal number including the century
598 	 * - \%z: the time zone as an offset from UTC (+hhmm)
599 	 * - \%:z: the time zone as an offset from UTC (+hh:mm).
600 	 * This is a gnulib strftime() extension. Since: 2.38
601 	 * - \%::z: the time zone as an offset from UTC (+hh:mm:ss). This is a
602 	 * gnulib strftime() extension. Since: 2.38
603 	 * - \%:::z: the time zone as an offset from UTC, with : to necessary
604 	 * precision (e.g., -04, +05:30). This is a gnulib strftime() extension. Since: 2.38
605 	 * - \%Z: the time zone or name or abbreviation
606 	 * - \%\%: a literal \% character
607 	 *
608 	 * Some conversion specifications can be modified by preceding the
609 	 * conversion specifier by one or more modifier characters. The
610 	 * following modifiers are supported for many of the numeric
611 	 * conversions:
612 	 *
613 	 * - O: Use alternative numeric symbols, if the current locale supports those.
614 	 * - _: Pad a numeric result with spaces. This overrides the default padding
615 	 * for the specifier.
616 	 * - -: Do not pad a numeric result. This overrides the default padding
617 	 * for the specifier.
618 	 * - 0: Pad a numeric result with zeros. This overrides the default padding
619 	 * for the specifier.
620 	 *
621 	 * Params:
622 	 *     format = a valid UTF-8 string, containing the format for the
623 	 *         #GDateTime
624 	 *
625 	 * Returns: a newly allocated string formatted to the requested format
626 	 *     or %NULL in the case that there was an error. The string
627 	 *     should be freed with g_free().
628 	 *
629 	 * Since: 2.26
630 	 */
631 	public string format(string format)
632 	{
633 		auto retStr = g_date_time_format(gDateTime, Str.toStringz(format));
634 
635 		scope(exit) Str.freeString(retStr);
636 		return Str.toString(retStr);
637 	}
638 
639 	/**
640 	 * Retrieves the day of the month represented by @datetime in the gregorian
641 	 * calendar.
642 	 *
643 	 * Returns: the day of the month
644 	 *
645 	 * Since: 2.26
646 	 */
647 	public int getDayOfMonth()
648 	{
649 		return g_date_time_get_day_of_month(gDateTime);
650 	}
651 
652 	/**
653 	 * Retrieves the ISO 8601 day of the week on which @datetime falls (1 is
654 	 * Monday, 2 is Tuesday... 7 is Sunday).
655 	 *
656 	 * Returns: the day of the week
657 	 *
658 	 * Since: 2.26
659 	 */
660 	public int getDayOfWeek()
661 	{
662 		return g_date_time_get_day_of_week(gDateTime);
663 	}
664 
665 	/**
666 	 * Retrieves the day of the year represented by @datetime in the Gregorian
667 	 * calendar.
668 	 *
669 	 * Returns: the day of the year
670 	 *
671 	 * Since: 2.26
672 	 */
673 	public int getDayOfYear()
674 	{
675 		return g_date_time_get_day_of_year(gDateTime);
676 	}
677 
678 	/**
679 	 * Retrieves the hour of the day represented by @datetime
680 	 *
681 	 * Returns: the hour of the day
682 	 *
683 	 * Since: 2.26
684 	 */
685 	public int getHour()
686 	{
687 		return g_date_time_get_hour(gDateTime);
688 	}
689 
690 	/**
691 	 * Retrieves the microsecond of the date represented by @datetime
692 	 *
693 	 * Returns: the microsecond of the second
694 	 *
695 	 * Since: 2.26
696 	 */
697 	public int getMicrosecond()
698 	{
699 		return g_date_time_get_microsecond(gDateTime);
700 	}
701 
702 	/**
703 	 * Retrieves the minute of the hour represented by @datetime
704 	 *
705 	 * Returns: the minute of the hour
706 	 *
707 	 * Since: 2.26
708 	 */
709 	public int getMinute()
710 	{
711 		return g_date_time_get_minute(gDateTime);
712 	}
713 
714 	/**
715 	 * Retrieves the month of the year represented by @datetime in the Gregorian
716 	 * calendar.
717 	 *
718 	 * Returns: the month represented by @datetime
719 	 *
720 	 * Since: 2.26
721 	 */
722 	public int getMonth()
723 	{
724 		return g_date_time_get_month(gDateTime);
725 	}
726 
727 	/**
728 	 * Retrieves the second of the minute represented by @datetime
729 	 *
730 	 * Returns: the second represented by @datetime
731 	 *
732 	 * Since: 2.26
733 	 */
734 	public int getSecond()
735 	{
736 		return g_date_time_get_second(gDateTime);
737 	}
738 
739 	/**
740 	 * Retrieves the number of seconds since the start of the last minute,
741 	 * including the fractional part.
742 	 *
743 	 * Returns: the number of seconds
744 	 *
745 	 * Since: 2.26
746 	 */
747 	public double getSeconds()
748 	{
749 		return g_date_time_get_seconds(gDateTime);
750 	}
751 
752 	/**
753 	 * Determines the time zone abbreviation to be used at the time and in
754 	 * the time zone of @datetime.
755 	 *
756 	 * For example, in Toronto this is currently "EST" during the winter
757 	 * months and "EDT" during the summer months when daylight savings
758 	 * time is in effect.
759 	 *
760 	 * Returns: the time zone abbreviation. The returned
761 	 *     string is owned by the #GDateTime and it should not be
762 	 *     modified or freed
763 	 *
764 	 * Since: 2.26
765 	 */
766 	public string getTimezoneAbbreviation()
767 	{
768 		return Str.toString(g_date_time_get_timezone_abbreviation(gDateTime));
769 	}
770 
771 	/**
772 	 * Determines the offset to UTC in effect at the time and in the time
773 	 * zone of @datetime.
774 	 *
775 	 * The offset is the number of microseconds that you add to UTC time to
776 	 * arrive at local time for the time zone (ie: negative numbers for time
777 	 * zones west of GMT, positive numbers for east).
778 	 *
779 	 * If @datetime represents UTC time, then the offset is always zero.
780 	 *
781 	 * Returns: the number of microseconds that should be added to UTC to
782 	 *     get the local time
783 	 *
784 	 * Since: 2.26
785 	 */
786 	public GTimeSpan getUtcOffset()
787 	{
788 		return g_date_time_get_utc_offset(gDateTime);
789 	}
790 
791 	/**
792 	 * Returns the ISO 8601 week-numbering year in which the week containing
793 	 * @datetime falls.
794 	 *
795 	 * This function, taken together with g_date_time_get_week_of_year() and
796 	 * g_date_time_get_day_of_week() can be used to determine the full ISO
797 	 * week date on which @datetime falls.
798 	 *
799 	 * This is usually equal to the normal Gregorian year (as returned by
800 	 * g_date_time_get_year()), except as detailed below:
801 	 *
802 	 * For Thursday, the week-numbering year is always equal to the usual
803 	 * calendar year.  For other days, the number is such that every day
804 	 * within a complete week (Monday to Sunday) is contained within the
805 	 * same week-numbering year.
806 	 *
807 	 * For Monday, Tuesday and Wednesday occurring near the end of the year,
808 	 * this may mean that the week-numbering year is one greater than the
809 	 * calendar year (so that these days have the same week-numbering year
810 	 * as the Thursday occurring early in the next year).
811 	 *
812 	 * For Friday, Saturday and Sunday occurring near the start of the year,
813 	 * this may mean that the week-numbering year is one less than the
814 	 * calendar year (so that these days have the same week-numbering year
815 	 * as the Thursday occurring late in the previous year).
816 	 *
817 	 * An equivalent description is that the week-numbering year is equal to
818 	 * the calendar year containing the majority of the days in the current
819 	 * week (Monday to Sunday).
820 	 *
821 	 * Note that January 1 0001 in the proleptic Gregorian calendar is a
822 	 * Monday, so this function never returns 0.
823 	 *
824 	 * Returns: the ISO 8601 week-numbering year for @datetime
825 	 *
826 	 * Since: 2.26
827 	 */
828 	public int getWeekNumberingYear()
829 	{
830 		return g_date_time_get_week_numbering_year(gDateTime);
831 	}
832 
833 	/**
834 	 * Returns the ISO 8601 week number for the week containing @datetime.
835 	 * The ISO 8601 week number is the same for every day of the week (from
836 	 * Moday through Sunday).  That can produce some unusual results
837 	 * (described below).
838 	 *
839 	 * The first week of the year is week 1.  This is the week that contains
840 	 * the first Thursday of the year.  Equivalently, this is the first week
841 	 * that has more than 4 of its days falling within the calendar year.
842 	 *
843 	 * The value 0 is never returned by this function.  Days contained
844 	 * within a year but occurring before the first ISO 8601 week of that
845 	 * year are considered as being contained in the last week of the
846 	 * previous year.  Similarly, the final days of a calendar year may be
847 	 * considered as being part of the first ISO 8601 week of the next year
848 	 * if 4 or more days of that week are contained within the new year.
849 	 *
850 	 * Returns: the ISO 8601 week number for @datetime.
851 	 *
852 	 * Since: 2.26
853 	 */
854 	public int getWeekOfYear()
855 	{
856 		return g_date_time_get_week_of_year(gDateTime);
857 	}
858 
859 	/**
860 	 * Retrieves the year represented by @datetime in the Gregorian calendar.
861 	 *
862 	 * Returns: the year represented by @datetime
863 	 *
864 	 * Since: 2.26
865 	 */
866 	public int getYear()
867 	{
868 		return g_date_time_get_year(gDateTime);
869 	}
870 
871 	/**
872 	 * Retrieves the Gregorian day, month, and year of a given #GDateTime.
873 	 *
874 	 * Params:
875 	 *     year = the return location for the gregorian year, or %NULL.
876 	 *     month = the return location for the month of the year, or %NULL.
877 	 *     day = the return location for the day of the month, or %NULL.
878 	 *
879 	 * Since: 2.26
880 	 */
881 	public void getYmd(out int year, out int month, out int day)
882 	{
883 		g_date_time_get_ymd(gDateTime, &year, &month, &day);
884 	}
885 
886 	/**
887 	 * Determines if daylight savings time is in effect at the time and in
888 	 * the time zone of @datetime.
889 	 *
890 	 * Returns: %TRUE if daylight savings time is in effect
891 	 *
892 	 * Since: 2.26
893 	 */
894 	public bool isDaylightSavings()
895 	{
896 		return g_date_time_is_daylight_savings(gDateTime) != 0;
897 	}
898 
899 	/**
900 	 * Atomically increments the reference count of @datetime by one.
901 	 *
902 	 * Returns: the #GDateTime with the reference count increased
903 	 *
904 	 * Since: 2.26
905 	 */
906 	public DateTime doref()
907 	{
908 		auto p = g_date_time_ref(gDateTime);
909 
910 		if(p is null)
911 		{
912 			return null;
913 		}
914 
915 		return new DateTime(cast(GDateTime*) p, true);
916 	}
917 
918 	/**
919 	 * Creates a new #GDateTime corresponding to the same instant in time as
920 	 * @datetime, but in the local time zone.
921 	 *
922 	 * This call is equivalent to calling g_date_time_to_timezone() with the
923 	 * time zone returned by g_time_zone_new_local().
924 	 *
925 	 * Returns: the newly created #GDateTime
926 	 *
927 	 * Since: 2.26
928 	 */
929 	public DateTime toLocal()
930 	{
931 		auto p = g_date_time_to_local(gDateTime);
932 
933 		if(p is null)
934 		{
935 			return null;
936 		}
937 
938 		return new DateTime(cast(GDateTime*) p, true);
939 	}
940 
941 	/**
942 	 * Stores the instant in time that @datetime represents into @tv.
943 	 *
944 	 * The time contained in a #GTimeVal is always stored in the form of
945 	 * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time
946 	 * zone associated with @datetime.
947 	 *
948 	 * On systems where 'long' is 32bit (ie: all 32bit systems and all
949 	 * Windows systems), a #GTimeVal is incapable of storing the entire
950 	 * range of values that #GDateTime is capable of expressing.  On those
951 	 * systems, this function returns %FALSE to indicate that the time is
952 	 * out of range.
953 	 *
954 	 * On systems where 'long' is 64bit, this function never fails.
955 	 *
956 	 * Params:
957 	 *     tv = a #GTimeVal to modify
958 	 *
959 	 * Returns: %TRUE if successful, else %FALSE
960 	 *
961 	 * Since: 2.26
962 	 */
963 	public bool toTimeval(TimeVal tv)
964 	{
965 		return g_date_time_to_timeval(gDateTime, (tv is null) ? null : tv.getTimeValStruct()) != 0;
966 	}
967 
968 	/**
969 	 * Create a new #GDateTime corresponding to the same instant in time as
970 	 * @datetime, but in the time zone @tz.
971 	 *
972 	 * This call can fail in the case that the time goes out of bounds.  For
973 	 * example, converting 0001-01-01 00:00:00 UTC to a time zone west of
974 	 * Greenwich will fail (due to the year 0 being out of range).
975 	 *
976 	 * You should release the return value by calling g_date_time_unref()
977 	 * when you are done with it.
978 	 *
979 	 * Params:
980 	 *     tz = the new #GTimeZone
981 	 *
982 	 * Returns: a new #GDateTime, or %NULL
983 	 *
984 	 * Since: 2.26
985 	 */
986 	public DateTime toTimezone(TimeZone tz)
987 	{
988 		auto p = g_date_time_to_timezone(gDateTime, (tz is null) ? null : tz.getTimeZoneStruct());
989 
990 		if(p is null)
991 		{
992 			return null;
993 		}
994 
995 		return new DateTime(cast(GDateTime*) p, true);
996 	}
997 
998 	/**
999 	 * Gives the Unix time corresponding to @datetime, rounding down to the
1000 	 * nearest second.
1001 	 *
1002 	 * Unix time is the number of seconds that have elapsed since 1970-01-01
1003 	 * 00:00:00 UTC, regardless of the time zone associated with @datetime.
1004 	 *
1005 	 * Returns: the Unix time corresponding to @datetime
1006 	 *
1007 	 * Since: 2.26
1008 	 */
1009 	public long toUnix()
1010 	{
1011 		return g_date_time_to_unix(gDateTime);
1012 	}
1013 
1014 	/**
1015 	 * Creates a new #GDateTime corresponding to the same instant in time as
1016 	 * @datetime, but in UTC.
1017 	 *
1018 	 * This call is equivalent to calling g_date_time_to_timezone() with the
1019 	 * time zone returned by g_time_zone_new_utc().
1020 	 *
1021 	 * Returns: the newly created #GDateTime
1022 	 *
1023 	 * Since: 2.26
1024 	 */
1025 	public DateTime toUtc()
1026 	{
1027 		auto p = g_date_time_to_utc(gDateTime);
1028 
1029 		if(p is null)
1030 		{
1031 			return null;
1032 		}
1033 
1034 		return new DateTime(cast(GDateTime*) p, true);
1035 	}
1036 
1037 	/**
1038 	 * Atomically decrements the reference count of @datetime by one.
1039 	 *
1040 	 * When the reference count reaches zero, the resources allocated by
1041 	 * @datetime are freed
1042 	 *
1043 	 * Since: 2.26
1044 	 */
1045 	public void unref()
1046 	{
1047 		g_date_time_unref(gDateTime);
1048 	}
1049 
1050 	/**
1051 	 * A comparison function for #GDateTimes that is suitable
1052 	 * as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
1053 	 *
1054 	 * Params:
1055 	 *     dt1 = first #GDateTime to compare
1056 	 *     dt2 = second #GDateTime to compare
1057 	 *
1058 	 * Returns: -1, 0 or 1 if @dt1 is less than, equal to or greater
1059 	 *     than @dt2.
1060 	 *
1061 	 * Since: 2.26
1062 	 */
1063 	public static int compare(DateTime dt1, DateTime dt2)
1064 	{
1065 		return g_date_time_compare((dt1 is null) ? null : dt1.getDateTimeStruct(), (dt2 is null) ? null : dt2.getDateTimeStruct());
1066 	}
1067 
1068 	/**
1069 	 * Checks to see if @dt1 and @dt2 are equal.
1070 	 *
1071 	 * Equal here means that they represent the same moment after converting
1072 	 * them to the same time zone.
1073 	 *
1074 	 * Params:
1075 	 *     dt1 = a #GDateTime
1076 	 *     dt2 = a #GDateTime
1077 	 *
1078 	 * Returns: %TRUE if @dt1 and @dt2 are equal
1079 	 *
1080 	 * Since: 2.26
1081 	 */
1082 	public static bool equal(DateTime dt1, DateTime dt2)
1083 	{
1084 		return g_date_time_equal((dt1 is null) ? null : dt1.getDateTimeStruct(), (dt2 is null) ? null : dt2.getDateTimeStruct()) != 0;
1085 	}
1086 }