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