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 the given
264 	 * [ISO 8601 formatted string](https://en.wikipedia.org/wiki/ISO_8601)
265 	 * @text. ISO 8601 strings of the form <date><sep><time><tz> are supported, with
266 	 * some extensions from [RFC 3339](https://tools.ietf.org/html/rfc3339) as
267 	 * mentioned below.
268 	 *
269 	 * Note that as #GDateTime "is oblivious to leap seconds", leap seconds information
270 	 * in an ISO-8601 string will be ignored, so a `23:59:60` time would be parsed as
271 	 * `23:59:59`.
272 	 *
273 	 * <sep> is the separator and can be either 'T', 't' or ' '. The latter two
274 	 * separators are an extension from
275 	 * [RFC 3339](https://tools.ietf.org/html/rfc3339#section-5.6).
276 	 *
277 	 * <date> is in the form:
278 	 *
279 	 * - `YYYY-MM-DD` - Year/month/day, e.g. 2016-08-24.
280 	 * - `YYYYMMDD` - Same as above without dividers.
281 	 * - `YYYY-DDD` - Ordinal day where DDD is from 001 to 366, e.g. 2016-237.
282 	 * - `YYYYDDD` - Same as above without dividers.
283 	 * - `YYYY-Www-D` - Week day where ww is from 01 to 52 and D from 1-7,
284 	 * e.g. 2016-W34-3.
285 	 * - `YYYYWwwD` - Same as above without dividers.
286 	 *
287 	 * <time> is in the form:
288 	 *
289 	 * - `hh:mm:ss(.sss)` - Hours, minutes, seconds (subseconds), e.g. 22:10:42.123.
290 	 * - `hhmmss(.sss)` - Same as above without dividers.
291 	 *
292 	 * <tz> is an optional timezone suffix of the form:
293 	 *
294 	 * - `Z` - UTC.
295 	 * - `+hh:mm` or `-hh:mm` - Offset from UTC in hours and minutes, e.g. +12:00.
296 	 * - `+hh` or `-hh` - Offset from UTC in hours, e.g. +12.
297 	 *
298 	 * If the timezone is not provided in @text it must be provided in @default_tz
299 	 * (this field is otherwise ignored).
300 	 *
301 	 * This call can fail (returning %NULL) if @text is not a valid ISO 8601
302 	 * formatted string.
303 	 *
304 	 * You should release the return value by calling g_date_time_unref()
305 	 * when you are done with it.
306 	 *
307 	 * Params:
308 	 *     text = an ISO 8601 formatted time string.
309 	 *     defaultTz = a #GTimeZone to use if the text doesn't contain a
310 	 *         timezone, or %NULL.
311 	 *
312 	 * Returns: a new #GDateTime, or %NULL
313 	 *
314 	 * Since: 2.56
315 	 *
316 	 * Throws: ConstructionException GTK+ fails to create the object.
317 	 */
318 	public this(string text, TimeZone defaultTz)
319 	{
320 		auto __p = g_date_time_new_from_iso8601(Str.toStringz(text), (defaultTz is null) ? null : defaultTz.getTimeZoneStruct());
321 
322 		if(__p is null)
323 		{
324 			throw new ConstructionException("null returned by new_from_iso8601");
325 		}
326 
327 		this(cast(GDateTime*) __p);
328 	}
329 
330 	/**
331 	 * Creates a #GDateTime corresponding to this exact instant in the given
332 	 * time zone @tz.  The time is as accurate as the system allows, to a
333 	 * maximum accuracy of 1 microsecond.
334 	 *
335 	 * This function will always succeed unless the system clock is set to
336 	 * truly insane values (or unless GLib is still being used after the
337 	 * year 9999).
338 	 *
339 	 * You should release the return value by calling g_date_time_unref()
340 	 * when you are done with it.
341 	 *
342 	 * Params:
343 	 *     tz = a #GTimeZone
344 	 *
345 	 * Returns: a new #GDateTime, or %NULL
346 	 *
347 	 * Since: 2.26
348 	 *
349 	 * Throws: ConstructionException GTK+ fails to create the object.
350 	 */
351 	public this(TimeZone tz)
352 	{
353 		auto __p = g_date_time_new_now((tz is null) ? null : tz.getTimeZoneStruct());
354 
355 		if(__p is null)
356 		{
357 			throw new ConstructionException("null returned by new_now");
358 		}
359 
360 		this(cast(GDateTime*) __p);
361 	}
362 
363 	/**
364 	 * Creates a copy of @datetime and adds the specified timespan to the copy.
365 	 *
366 	 * Params:
367 	 *     timespan = a #GTimeSpan
368 	 *
369 	 * Returns: the newly created #GDateTime which should be freed with
370 	 *     g_date_time_unref().
371 	 *
372 	 * Since: 2.26
373 	 */
374 	public DateTime add(GTimeSpan timespan)
375 	{
376 		auto __p = g_date_time_add(gDateTime, timespan);
377 
378 		if(__p is null)
379 		{
380 			return null;
381 		}
382 
383 		return new DateTime(cast(GDateTime*) __p, true);
384 	}
385 
386 	/**
387 	 * Creates a copy of @datetime and adds the specified number of days to the
388 	 * copy. Add negative values to subtract days.
389 	 *
390 	 * Params:
391 	 *     days = the number of days
392 	 *
393 	 * Returns: the newly created #GDateTime which should be freed with
394 	 *     g_date_time_unref().
395 	 *
396 	 * Since: 2.26
397 	 */
398 	public DateTime addDays(int days)
399 	{
400 		auto __p = g_date_time_add_days(gDateTime, days);
401 
402 		if(__p is null)
403 		{
404 			return null;
405 		}
406 
407 		return new DateTime(cast(GDateTime*) __p, true);
408 	}
409 
410 	/**
411 	 * Creates a new #GDateTime adding the specified values to the current date and
412 	 * time in @datetime. Add negative values to subtract.
413 	 *
414 	 * Params:
415 	 *     years = the number of years to add
416 	 *     months = the number of months to add
417 	 *     days = the number of days to add
418 	 *     hours = the number of hours to add
419 	 *     minutes = the number of minutes to add
420 	 *     seconds = the number of seconds to add
421 	 *
422 	 * Returns: the newly created #GDateTime that should be freed with
423 	 *     g_date_time_unref().
424 	 *
425 	 * Since: 2.26
426 	 */
427 	public DateTime addFull(int years, int months, int days, int hours, int minutes, double seconds)
428 	{
429 		auto __p = g_date_time_add_full(gDateTime, years, months, days, hours, minutes, seconds);
430 
431 		if(__p is null)
432 		{
433 			return null;
434 		}
435 
436 		return new DateTime(cast(GDateTime*) __p, true);
437 	}
438 
439 	/**
440 	 * Creates a copy of @datetime and adds the specified number of hours.
441 	 * Add negative values to subtract hours.
442 	 *
443 	 * Params:
444 	 *     hours = the number of hours to add
445 	 *
446 	 * Returns: the newly created #GDateTime which should be freed with
447 	 *     g_date_time_unref().
448 	 *
449 	 * Since: 2.26
450 	 */
451 	public DateTime addHours(int hours)
452 	{
453 		auto __p = g_date_time_add_hours(gDateTime, hours);
454 
455 		if(__p is null)
456 		{
457 			return null;
458 		}
459 
460 		return new DateTime(cast(GDateTime*) __p, true);
461 	}
462 
463 	/**
464 	 * Creates a copy of @datetime adding the specified number of minutes.
465 	 * Add negative values to subtract minutes.
466 	 *
467 	 * Params:
468 	 *     minutes = the number of minutes to add
469 	 *
470 	 * Returns: the newly created #GDateTime which should be freed with
471 	 *     g_date_time_unref().
472 	 *
473 	 * Since: 2.26
474 	 */
475 	public DateTime addMinutes(int minutes)
476 	{
477 		auto __p = g_date_time_add_minutes(gDateTime, minutes);
478 
479 		if(__p is null)
480 		{
481 			return null;
482 		}
483 
484 		return new DateTime(cast(GDateTime*) __p, true);
485 	}
486 
487 	/**
488 	 * Creates a copy of @datetime and adds the specified number of months to the
489 	 * copy. Add negative values to subtract months.
490 	 *
491 	 * The day of the month of the resulting #GDateTime is clamped to the number
492 	 * of days in the updated calendar month. For example, if adding 1 month to
493 	 * 31st January 2018, the result would be 28th February 2018. In 2020 (a leap
494 	 * year), the result would be 29th February.
495 	 *
496 	 * Params:
497 	 *     months = the number of months
498 	 *
499 	 * Returns: the newly created #GDateTime which should be freed with
500 	 *     g_date_time_unref().
501 	 *
502 	 * Since: 2.26
503 	 */
504 	public DateTime addMonths(int months)
505 	{
506 		auto __p = g_date_time_add_months(gDateTime, months);
507 
508 		if(__p is null)
509 		{
510 			return null;
511 		}
512 
513 		return new DateTime(cast(GDateTime*) __p, true);
514 	}
515 
516 	/**
517 	 * Creates a copy of @datetime and adds the specified number of seconds.
518 	 * Add negative values to subtract seconds.
519 	 *
520 	 * Params:
521 	 *     seconds = the number of seconds to add
522 	 *
523 	 * Returns: the newly created #GDateTime which should be freed with
524 	 *     g_date_time_unref().
525 	 *
526 	 * Since: 2.26
527 	 */
528 	public DateTime addSeconds(double seconds)
529 	{
530 		auto __p = g_date_time_add_seconds(gDateTime, seconds);
531 
532 		if(__p is null)
533 		{
534 			return null;
535 		}
536 
537 		return new DateTime(cast(GDateTime*) __p, true);
538 	}
539 
540 	/**
541 	 * Creates a copy of @datetime and adds the specified number of weeks to the
542 	 * copy. Add negative values to subtract weeks.
543 	 *
544 	 * Params:
545 	 *     weeks = the number of weeks
546 	 *
547 	 * Returns: the newly created #GDateTime which should be freed with
548 	 *     g_date_time_unref().
549 	 *
550 	 * Since: 2.26
551 	 */
552 	public DateTime addWeeks(int weeks)
553 	{
554 		auto __p = g_date_time_add_weeks(gDateTime, weeks);
555 
556 		if(__p is null)
557 		{
558 			return null;
559 		}
560 
561 		return new DateTime(cast(GDateTime*) __p, true);
562 	}
563 
564 	/**
565 	 * Creates a copy of @datetime and adds the specified number of years to the
566 	 * copy. Add negative values to subtract years.
567 	 *
568 	 * As with g_date_time_add_months(), if the resulting date would be 29th
569 	 * February on a non-leap year, the day will be clamped to 28th February.
570 	 *
571 	 * Params:
572 	 *     years = the number of years
573 	 *
574 	 * Returns: the newly created #GDateTime which should be freed with
575 	 *     g_date_time_unref().
576 	 *
577 	 * Since: 2.26
578 	 */
579 	public DateTime addYears(int years)
580 	{
581 		auto __p = g_date_time_add_years(gDateTime, years);
582 
583 		if(__p is null)
584 		{
585 			return null;
586 		}
587 
588 		return new DateTime(cast(GDateTime*) __p, true);
589 	}
590 
591 	/**
592 	 * Calculates the difference in time between @end and @begin.  The
593 	 * #GTimeSpan that is returned is effectively @end - @begin (ie:
594 	 * positive if the first parameter is larger).
595 	 *
596 	 * Params:
597 	 *     begin = a #GDateTime
598 	 *
599 	 * Returns: the difference between the two #GDateTime, as a time
600 	 *     span expressed in microseconds.
601 	 *
602 	 * Since: 2.26
603 	 */
604 	public GTimeSpan difference(DateTime begin)
605 	{
606 		return g_date_time_difference(gDateTime, (begin is null) ? null : begin.getDateTimeStruct());
607 	}
608 
609 	/**
610 	 * Creates a newly allocated string representing the requested @format.
611 	 *
612 	 * The format strings understood by this function are a subset of the
613 	 * strftime() format language as specified by C99.  The \%D, \%U and \%W
614 	 * conversions are not supported, nor is the 'E' modifier.  The GNU
615 	 * extensions \%k, \%l, \%s and \%P are supported, however, as are the
616 	 * '0', '_' and '-' modifiers.
617 	 *
618 	 * In contrast to strftime(), this function always produces a UTF-8
619 	 * string, regardless of the current locale.  Note that the rendering of
620 	 * many formats is locale-dependent and may not match the strftime()
621 	 * output exactly.
622 	 *
623 	 * The following format specifiers are supported:
624 	 *
625 	 * - \%a: the abbreviated weekday name according to the current locale
626 	 * - \%A: the full weekday name according to the current locale
627 	 * - \%b: the abbreviated month name according to the current locale
628 	 * - \%B: the full month name according to the current locale
629 	 * - \%c: the preferred date and time representation for the current locale
630 	 * - \%C: the century number (year/100) as a 2-digit integer (00-99)
631 	 * - \%d: the day of the month as a decimal number (range 01 to 31)
632 	 * - \%e: the day of the month as a decimal number (range  1 to 31)
633 	 * - \%F: equivalent to `%Y-%m-%d` (the ISO 8601 date format)
634 	 * - \%g: the last two digits of the ISO 8601 week-based year as a
635 	 * decimal number (00-99). This works well with \%V and \%u.
636 	 * - \%G: the ISO 8601 week-based year as a decimal number. This works
637 	 * well with \%V and \%u.
638 	 * - \%h: equivalent to \%b
639 	 * - \%H: the hour as a decimal number using a 24-hour clock (range 00 to 23)
640 	 * - \%I: the hour as a decimal number using a 12-hour clock (range 01 to 12)
641 	 * - \%j: the day of the year as a decimal number (range 001 to 366)
642 	 * - \%k: the hour (24-hour clock) as a decimal number (range 0 to 23);
643 	 * single digits are preceded by a blank
644 	 * - \%l: the hour (12-hour clock) as a decimal number (range 1 to 12);
645 	 * single digits are preceded by a blank
646 	 * - \%m: the month as a decimal number (range 01 to 12)
647 	 * - \%M: the minute as a decimal number (range 00 to 59)
648 	 * - \%p: either "AM" or "PM" according to the given time value, or the
649 	 * corresponding  strings for the current locale.  Noon is treated as
650 	 * "PM" and midnight as "AM".
651 	 * - \%P: like \%p but lowercase: "am" or "pm" or a corresponding string for
652 	 * the current locale
653 	 * - \%r: the time in a.m. or p.m. notation
654 	 * - \%R: the time in 24-hour notation (\%H:\%M)
655 	 * - \%s: the number of seconds since the Epoch, that is, since 1970-01-01
656 	 * 00:00:00 UTC
657 	 * - \%S: the second as a decimal number (range 00 to 60)
658 	 * - \%t: a tab character
659 	 * - \%T: the time in 24-hour notation with seconds (\%H:\%M:\%S)
660 	 * - \%u: the ISO 8601 standard day of the week as a decimal, range 1 to 7,
661 	 * Monday being 1. This works well with \%G and \%V.
662 	 * - \%V: the ISO 8601 standard week number of the current year as a decimal
663 	 * number, range 01 to 53, where week 1 is the first week that has at
664 	 * least 4 days in the new year. See g_date_time_get_week_of_year().
665 	 * This works well with \%G and \%u.
666 	 * - \%w: the day of the week as a decimal, range 0 to 6, Sunday being 0.
667 	 * This is not the ISO 8601 standard format -- use \%u instead.
668 	 * - \%x: the preferred date representation for the current locale without
669 	 * the time
670 	 * - \%X: the preferred time representation for the current locale without
671 	 * the date
672 	 * - \%y: the year as a decimal number without the century
673 	 * - \%Y: the year as a decimal number including the century
674 	 * - \%z: the time zone as an offset from UTC (+hhmm)
675 	 * - \%:z: the time zone as an offset from UTC (+hh:mm).
676 	 * This is a gnulib strftime() extension. Since: 2.38
677 	 * - \%::z: the time zone as an offset from UTC (+hh:mm:ss). This is a
678 	 * gnulib strftime() extension. Since: 2.38
679 	 * - \%:::z: the time zone as an offset from UTC, with : to necessary
680 	 * precision (e.g., -04, +05:30). This is a gnulib strftime() extension. Since: 2.38
681 	 * - \%Z: the time zone or name or abbreviation
682 	 * - \%\%: a literal \% character
683 	 *
684 	 * Some conversion specifications can be modified by preceding the
685 	 * conversion specifier by one or more modifier characters. The
686 	 * following modifiers are supported for many of the numeric
687 	 * conversions:
688 	 *
689 	 * - O: Use alternative numeric symbols, if the current locale supports those.
690 	 * - _: Pad a numeric result with spaces. This overrides the default padding
691 	 * for the specifier.
692 	 * - -: Do not pad a numeric result. This overrides the default padding
693 	 * for the specifier.
694 	 * - 0: Pad a numeric result with zeros. This overrides the default padding
695 	 * for the specifier.
696 	 *
697 	 * Additionally, when O is used with B, b, or h, it produces the alternative
698 	 * form of a month name. The alternative form should be used when the month
699 	 * name is used without a day number (e.g., standalone). It is required in
700 	 * some languages (Baltic, Slavic, Greek, and more) due to their grammatical
701 	 * rules. For other languages there is no difference. \%OB is a GNU and BSD
702 	 * strftime() extension expected to be added to the future POSIX specification,
703 	 * \%Ob and \%Oh are GNU strftime() extensions. Since: 2.56
704 	 *
705 	 * Params:
706 	 *     format = a valid UTF-8 string, containing the format for the
707 	 *         #GDateTime
708 	 *
709 	 * Returns: a newly allocated string formatted to the requested format
710 	 *     or %NULL in the case that there was an error (such as a format specifier
711 	 *     not being supported in the current locale). The string
712 	 *     should be freed with g_free().
713 	 *
714 	 * Since: 2.26
715 	 */
716 	public string format(string format)
717 	{
718 		auto retStr = g_date_time_format(gDateTime, Str.toStringz(format));
719 
720 		scope(exit) Str.freeString(retStr);
721 		return Str.toString(retStr);
722 	}
723 
724 	/**
725 	 * Format @datetime in [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601),
726 	 * including the date, time and time zone, and return that as a UTF-8 encoded
727 	 * string.
728 	 *
729 	 * Returns: a newly allocated string formatted in ISO 8601 format
730 	 *     or %NULL in the case that there was an error. The string
731 	 *     should be freed with g_free().
732 	 *
733 	 * Since: 2.62
734 	 */
735 	public string formatIso8601()
736 	{
737 		auto retStr = g_date_time_format_iso8601(gDateTime);
738 
739 		scope(exit) Str.freeString(retStr);
740 		return Str.toString(retStr);
741 	}
742 
743 	/**
744 	 * Retrieves the day of the month represented by @datetime in the gregorian
745 	 * calendar.
746 	 *
747 	 * Returns: the day of the month
748 	 *
749 	 * Since: 2.26
750 	 */
751 	public int getDayOfMonth()
752 	{
753 		return g_date_time_get_day_of_month(gDateTime);
754 	}
755 
756 	/**
757 	 * Retrieves the ISO 8601 day of the week on which @datetime falls (1 is
758 	 * Monday, 2 is Tuesday... 7 is Sunday).
759 	 *
760 	 * Returns: the day of the week
761 	 *
762 	 * Since: 2.26
763 	 */
764 	public int getDayOfWeek()
765 	{
766 		return g_date_time_get_day_of_week(gDateTime);
767 	}
768 
769 	/**
770 	 * Retrieves the day of the year represented by @datetime in the Gregorian
771 	 * calendar.
772 	 *
773 	 * Returns: the day of the year
774 	 *
775 	 * Since: 2.26
776 	 */
777 	public int getDayOfYear()
778 	{
779 		return g_date_time_get_day_of_year(gDateTime);
780 	}
781 
782 	/**
783 	 * Retrieves the hour of the day represented by @datetime
784 	 *
785 	 * Returns: the hour of the day
786 	 *
787 	 * Since: 2.26
788 	 */
789 	public int getHour()
790 	{
791 		return g_date_time_get_hour(gDateTime);
792 	}
793 
794 	/**
795 	 * Retrieves the microsecond of the date represented by @datetime
796 	 *
797 	 * Returns: the microsecond of the second
798 	 *
799 	 * Since: 2.26
800 	 */
801 	public int getMicrosecond()
802 	{
803 		return g_date_time_get_microsecond(gDateTime);
804 	}
805 
806 	/**
807 	 * Retrieves the minute of the hour represented by @datetime
808 	 *
809 	 * Returns: the minute of the hour
810 	 *
811 	 * Since: 2.26
812 	 */
813 	public int getMinute()
814 	{
815 		return g_date_time_get_minute(gDateTime);
816 	}
817 
818 	/**
819 	 * Retrieves the month of the year represented by @datetime in the Gregorian
820 	 * calendar.
821 	 *
822 	 * Returns: the month represented by @datetime
823 	 *
824 	 * Since: 2.26
825 	 */
826 	public int getMonth()
827 	{
828 		return g_date_time_get_month(gDateTime);
829 	}
830 
831 	/**
832 	 * Retrieves the second of the minute represented by @datetime
833 	 *
834 	 * Returns: the second represented by @datetime
835 	 *
836 	 * Since: 2.26
837 	 */
838 	public int getSecond()
839 	{
840 		return g_date_time_get_second(gDateTime);
841 	}
842 
843 	/**
844 	 * Retrieves the number of seconds since the start of the last minute,
845 	 * including the fractional part.
846 	 *
847 	 * Returns: the number of seconds
848 	 *
849 	 * Since: 2.26
850 	 */
851 	public double getSeconds()
852 	{
853 		return g_date_time_get_seconds(gDateTime);
854 	}
855 
856 	/**
857 	 * Get the time zone for this @datetime.
858 	 *
859 	 * Returns: the time zone
860 	 *
861 	 * Since: 2.58
862 	 */
863 	public TimeZone getTimezone()
864 	{
865 		auto __p = g_date_time_get_timezone(gDateTime);
866 
867 		if(__p is null)
868 		{
869 			return null;
870 		}
871 
872 		return new TimeZone(cast(GTimeZone*) __p);
873 	}
874 
875 	/**
876 	 * Determines the time zone abbreviation to be used at the time and in
877 	 * the time zone of @datetime.
878 	 *
879 	 * For example, in Toronto this is currently "EST" during the winter
880 	 * months and "EDT" during the summer months when daylight savings
881 	 * time is in effect.
882 	 *
883 	 * Returns: the time zone abbreviation. The returned
884 	 *     string is owned by the #GDateTime and it should not be
885 	 *     modified or freed
886 	 *
887 	 * Since: 2.26
888 	 */
889 	public string getTimezoneAbbreviation()
890 	{
891 		return Str.toString(g_date_time_get_timezone_abbreviation(gDateTime));
892 	}
893 
894 	/**
895 	 * Determines the offset to UTC in effect at the time and in the time
896 	 * zone of @datetime.
897 	 *
898 	 * The offset is the number of microseconds that you add to UTC time to
899 	 * arrive at local time for the time zone (ie: negative numbers for time
900 	 * zones west of GMT, positive numbers for east).
901 	 *
902 	 * If @datetime represents UTC time, then the offset is always zero.
903 	 *
904 	 * Returns: the number of microseconds that should be added to UTC to
905 	 *     get the local time
906 	 *
907 	 * Since: 2.26
908 	 */
909 	public GTimeSpan getUtcOffset()
910 	{
911 		return g_date_time_get_utc_offset(gDateTime);
912 	}
913 
914 	/**
915 	 * Returns the ISO 8601 week-numbering year in which the week containing
916 	 * @datetime falls.
917 	 *
918 	 * This function, taken together with g_date_time_get_week_of_year() and
919 	 * g_date_time_get_day_of_week() can be used to determine the full ISO
920 	 * week date on which @datetime falls.
921 	 *
922 	 * This is usually equal to the normal Gregorian year (as returned by
923 	 * g_date_time_get_year()), except as detailed below:
924 	 *
925 	 * For Thursday, the week-numbering year is always equal to the usual
926 	 * calendar year.  For other days, the number is such that every day
927 	 * within a complete week (Monday to Sunday) is contained within the
928 	 * same week-numbering year.
929 	 *
930 	 * For Monday, Tuesday and Wednesday occurring near the end of the year,
931 	 * this may mean that the week-numbering year is one greater than the
932 	 * calendar year (so that these days have the same week-numbering year
933 	 * as the Thursday occurring early in the next year).
934 	 *
935 	 * For Friday, Saturday and Sunday occurring near the start of the year,
936 	 * this may mean that the week-numbering year is one less than the
937 	 * calendar year (so that these days have the same week-numbering year
938 	 * as the Thursday occurring late in the previous year).
939 	 *
940 	 * An equivalent description is that the week-numbering year is equal to
941 	 * the calendar year containing the majority of the days in the current
942 	 * week (Monday to Sunday).
943 	 *
944 	 * Note that January 1 0001 in the proleptic Gregorian calendar is a
945 	 * Monday, so this function never returns 0.
946 	 *
947 	 * Returns: the ISO 8601 week-numbering year for @datetime
948 	 *
949 	 * Since: 2.26
950 	 */
951 	public int getWeekNumberingYear()
952 	{
953 		return g_date_time_get_week_numbering_year(gDateTime);
954 	}
955 
956 	/**
957 	 * Returns the ISO 8601 week number for the week containing @datetime.
958 	 * The ISO 8601 week number is the same for every day of the week (from
959 	 * Moday through Sunday).  That can produce some unusual results
960 	 * (described below).
961 	 *
962 	 * The first week of the year is week 1.  This is the week that contains
963 	 * the first Thursday of the year.  Equivalently, this is the first week
964 	 * that has more than 4 of its days falling within the calendar year.
965 	 *
966 	 * The value 0 is never returned by this function.  Days contained
967 	 * within a year but occurring before the first ISO 8601 week of that
968 	 * year are considered as being contained in the last week of the
969 	 * previous year.  Similarly, the final days of a calendar year may be
970 	 * considered as being part of the first ISO 8601 week of the next year
971 	 * if 4 or more days of that week are contained within the new year.
972 	 *
973 	 * Returns: the ISO 8601 week number for @datetime.
974 	 *
975 	 * Since: 2.26
976 	 */
977 	public int getWeekOfYear()
978 	{
979 		return g_date_time_get_week_of_year(gDateTime);
980 	}
981 
982 	/**
983 	 * Retrieves the year represented by @datetime in the Gregorian calendar.
984 	 *
985 	 * Returns: the year represented by @datetime
986 	 *
987 	 * Since: 2.26
988 	 */
989 	public int getYear()
990 	{
991 		return g_date_time_get_year(gDateTime);
992 	}
993 
994 	/**
995 	 * Retrieves the Gregorian day, month, and year of a given #GDateTime.
996 	 *
997 	 * Params:
998 	 *     year = the return location for the gregorian year, or %NULL.
999 	 *     month = the return location for the month of the year, or %NULL.
1000 	 *     day = the return location for the day of the month, or %NULL.
1001 	 *
1002 	 * Since: 2.26
1003 	 */
1004 	public void getYmd(out int year, out int month, out int day)
1005 	{
1006 		g_date_time_get_ymd(gDateTime, &year, &month, &day);
1007 	}
1008 
1009 	/**
1010 	 * Determines if daylight savings time is in effect at the time and in
1011 	 * the time zone of @datetime.
1012 	 *
1013 	 * Returns: %TRUE if daylight savings time is in effect
1014 	 *
1015 	 * Since: 2.26
1016 	 */
1017 	public bool isDaylightSavings()
1018 	{
1019 		return g_date_time_is_daylight_savings(gDateTime) != 0;
1020 	}
1021 
1022 	alias doref = ref_;
1023 	/**
1024 	 * Atomically increments the reference count of @datetime by one.
1025 	 *
1026 	 * Returns: the #GDateTime with the reference count increased
1027 	 *
1028 	 * Since: 2.26
1029 	 */
1030 	public DateTime ref_()
1031 	{
1032 		auto __p = g_date_time_ref(gDateTime);
1033 
1034 		if(__p is null)
1035 		{
1036 			return null;
1037 		}
1038 
1039 		return new DateTime(cast(GDateTime*) __p, true);
1040 	}
1041 
1042 	/**
1043 	 * Creates a new #GDateTime corresponding to the same instant in time as
1044 	 * @datetime, but in the local time zone.
1045 	 *
1046 	 * This call is equivalent to calling g_date_time_to_timezone() with the
1047 	 * time zone returned by g_time_zone_new_local().
1048 	 *
1049 	 * Returns: the newly created #GDateTime
1050 	 *
1051 	 * Since: 2.26
1052 	 */
1053 	public DateTime toLocal()
1054 	{
1055 		auto __p = g_date_time_to_local(gDateTime);
1056 
1057 		if(__p is null)
1058 		{
1059 			return null;
1060 		}
1061 
1062 		return new DateTime(cast(GDateTime*) __p, true);
1063 	}
1064 
1065 	/**
1066 	 * Stores the instant in time that @datetime represents into @tv.
1067 	 *
1068 	 * The time contained in a #GTimeVal is always stored in the form of
1069 	 * seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time
1070 	 * zone associated with @datetime.
1071 	 *
1072 	 * On systems where 'long' is 32bit (ie: all 32bit systems and all
1073 	 * Windows systems), a #GTimeVal is incapable of storing the entire
1074 	 * range of values that #GDateTime is capable of expressing.  On those
1075 	 * systems, this function returns %FALSE to indicate that the time is
1076 	 * out of range.
1077 	 *
1078 	 * On systems where 'long' is 64bit, this function never fails.
1079 	 *
1080 	 * Deprecated: #GTimeVal is not year-2038-safe. Use
1081 	 * g_date_time_to_unix() instead.
1082 	 *
1083 	 * Params:
1084 	 *     tv = a #GTimeVal to modify
1085 	 *
1086 	 * Returns: %TRUE if successful, else %FALSE
1087 	 *
1088 	 * Since: 2.26
1089 	 */
1090 	public bool toTimeval(TimeVal tv)
1091 	{
1092 		return g_date_time_to_timeval(gDateTime, (tv is null) ? null : tv.getTimeValStruct()) != 0;
1093 	}
1094 
1095 	/**
1096 	 * Create a new #GDateTime corresponding to the same instant in time as
1097 	 * @datetime, but in the time zone @tz.
1098 	 *
1099 	 * This call can fail in the case that the time goes out of bounds.  For
1100 	 * example, converting 0001-01-01 00:00:00 UTC to a time zone west of
1101 	 * Greenwich will fail (due to the year 0 being out of range).
1102 	 *
1103 	 * You should release the return value by calling g_date_time_unref()
1104 	 * when you are done with it.
1105 	 *
1106 	 * Params:
1107 	 *     tz = the new #GTimeZone
1108 	 *
1109 	 * Returns: a new #GDateTime, or %NULL
1110 	 *
1111 	 * Since: 2.26
1112 	 */
1113 	public DateTime toTimezone(TimeZone tz)
1114 	{
1115 		auto __p = g_date_time_to_timezone(gDateTime, (tz is null) ? null : tz.getTimeZoneStruct());
1116 
1117 		if(__p is null)
1118 		{
1119 			return null;
1120 		}
1121 
1122 		return new DateTime(cast(GDateTime*) __p, true);
1123 	}
1124 
1125 	/**
1126 	 * Gives the Unix time corresponding to @datetime, rounding down to the
1127 	 * nearest second.
1128 	 *
1129 	 * Unix time is the number of seconds that have elapsed since 1970-01-01
1130 	 * 00:00:00 UTC, regardless of the time zone associated with @datetime.
1131 	 *
1132 	 * Returns: the Unix time corresponding to @datetime
1133 	 *
1134 	 * Since: 2.26
1135 	 */
1136 	public long toUnix()
1137 	{
1138 		return g_date_time_to_unix(gDateTime);
1139 	}
1140 
1141 	/**
1142 	 * Creates a new #GDateTime corresponding to the same instant in time as
1143 	 * @datetime, but in UTC.
1144 	 *
1145 	 * This call is equivalent to calling g_date_time_to_timezone() with the
1146 	 * time zone returned by g_time_zone_new_utc().
1147 	 *
1148 	 * Returns: the newly created #GDateTime
1149 	 *
1150 	 * Since: 2.26
1151 	 */
1152 	public DateTime toUtc()
1153 	{
1154 		auto __p = g_date_time_to_utc(gDateTime);
1155 
1156 		if(__p is null)
1157 		{
1158 			return null;
1159 		}
1160 
1161 		return new DateTime(cast(GDateTime*) __p, true);
1162 	}
1163 
1164 	/**
1165 	 * Atomically decrements the reference count of @datetime by one.
1166 	 *
1167 	 * When the reference count reaches zero, the resources allocated by
1168 	 * @datetime are freed
1169 	 *
1170 	 * Since: 2.26
1171 	 */
1172 	public void unref()
1173 	{
1174 		g_date_time_unref(gDateTime);
1175 	}
1176 
1177 	/**
1178 	 * A comparison function for #GDateTimes that is suitable
1179 	 * as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
1180 	 *
1181 	 * Params:
1182 	 *     dt1 = first #GDateTime to compare
1183 	 *     dt2 = second #GDateTime to compare
1184 	 *
1185 	 * Returns: -1, 0 or 1 if @dt1 is less than, equal to or greater
1186 	 *     than @dt2.
1187 	 *
1188 	 * Since: 2.26
1189 	 */
1190 	public static int compare(DateTime dt1, DateTime dt2)
1191 	{
1192 		return g_date_time_compare((dt1 is null) ? null : dt1.getDateTimeStruct(), (dt2 is null) ? null : dt2.getDateTimeStruct());
1193 	}
1194 
1195 	/**
1196 	 * Checks to see if @dt1 and @dt2 are equal.
1197 	 *
1198 	 * Equal here means that they represent the same moment after converting
1199 	 * them to the same time zone.
1200 	 *
1201 	 * Params:
1202 	 *     dt1 = a #GDateTime
1203 	 *     dt2 = a #GDateTime
1204 	 *
1205 	 * Returns: %TRUE if @dt1 and @dt2 are equal
1206 	 *
1207 	 * Since: 2.26
1208 	 */
1209 	public static bool equal(DateTime dt1, DateTime dt2)
1210 	{
1211 		return g_date_time_equal((dt1 is null) ? null : dt1.getDateTimeStruct(), (dt2 is null) ? null : dt2.getDateTimeStruct()) != 0;
1212 	}
1213 }