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