glib.date_time
Module for [DateTime] class
Types 1
[glib.date_time.DateTime] is a structure that combines a Gregorian date and time into a single structure.
[glib.date_time.DateTime] provides many conversion and methods to manipulate dates and times. Time precision is provided down to microseconds and the time can range (proleptically) from 0001-01-01 00:00:00 to 9999-12-31 23:59:59.999999. [glib.date_time.DateTime] follows POSIX time in the sense that it is oblivious to leap seconds.
[glib.date_time.DateTime] is an immutable object; once it has been created it cannot be modified further. All modifiers will create a new [glib.date_time.DateTime]. Nearly all such functions can fail due to the date or time going out of range, in which case null will be returned.
[glib.date_time.DateTime] is reference counted: the reference count is increased by calling [glib.date_time.DateTime.ref_] and decreased by calling [glib.date_time.DateTime.unref]. When the reference count drops to 0, the resources allocated by the [glib.date_time.DateTime] structure are released.
Many parts of the API may produce non-obvious results. As an example, adding two months to January 31st will yield March 31st whereas adding one month and then one month again will yield either March 28th or March 29th. Also note that adding 24 hours is not always the same as adding one day (since days containing daylight savings time transitions are either 23 or 25 hours in length).
glib.date_time.DateTime newFromIso8601(string text, glib.time_zone.TimeZone defaultTz = null)Creates a #GDateTime corresponding to the given [ISO 8601 formatted string](https://en.wikipedia.org/wiki/ISO_8601) text. ISO 8601 strings of the form <date><sep><time><tz> are supported, with some...glib.date_time.DateTime newFromTimevalLocal(glib.time_val.TimeVal tv)Creates a #GDateTime corresponding to the given #GTimeVal tv in the local time zone.glib.date_time.DateTime newFromTimevalUtc(glib.time_val.TimeVal tv)Creates a #GDateTime corresponding to the given #GTimeVal tv in UTC.glib.date_time.DateTime newFromUnixLocal(long t)Creates a #GDateTime corresponding to the given Unix time `t` in the local time zone.glib.date_time.DateTime newFromUnixLocalUsec(long usecs)Creates a [glib.date_time.DateTime] corresponding to the given Unix time t in the local time zone.glib.date_time.DateTime newFromUnixUtc(long t)Creates a #GDateTime corresponding to the given Unix time `t` in UTC.glib.date_time.DateTime newFromUnixUtcUsec(long usecs)Creates a [glib.date_time.DateTime] corresponding to the given Unix time t in UTC.glib.date_time.DateTime newLocal(int year, int month, int day, int hour, int minute, double seconds)Creates a new #GDateTime corresponding to the given date and time in the local time zone.glib.date_time.DateTime newNow(glib.time_zone.TimeZone tz)Creates a #GDateTime corresponding to this exact instant in the given time zone tz. The time is as accurate as the system allows, to a maximum accuracy of 1 microsecond.glib.date_time.DateTime newNowLocal()Creates a #GDateTime corresponding to this exact instant in the local time zone.glib.date_time.DateTime newNowUtc()Creates a #GDateTime corresponding to this exact instant in UTC.glib.date_time.DateTime newUtc(int year, int month, int day, int hour, int minute, double seconds)Creates a new #GDateTime corresponding to the given date and time in UTC.glib.date_time.DateTime add(glib.types.TimeSpan timespan)Creates a copy of datetime and adds the specified timespan to the copy.glib.date_time.DateTime addDays(int days)Creates a copy of datetime and adds the specified number of days to the copy. Add negative values to subtract days.glib.date_time.DateTime addFull(int years, int months, int days, int hours, int minutes, double seconds)Creates a new #GDateTime adding the specified values to the current date and time in datetime. Add negative values to subtract.glib.date_time.DateTime addHours(int hours)Creates a copy of datetime and adds the specified number of hours. Add negative values to subtract hours.glib.date_time.DateTime addMinutes(int minutes)Creates a copy of datetime adding the specified number of minutes. Add negative values to subtract minutes.glib.date_time.DateTime addMonths(int months)Creates a copy of datetime and adds the specified number of months to the copy. Add negative values to subtract months.glib.date_time.DateTime addSeconds(double seconds)Creates a copy of datetime and adds the specified number of seconds. Add negative values to subtract seconds.glib.date_time.DateTime addWeeks(int weeks)Creates a copy of datetime and adds the specified number of weeks to the copy. Add negative values to subtract weeks.glib.date_time.DateTime addYears(int years)Creates a copy of datetime and adds the specified number of years to the copy. Add negative values to subtract years.int compare(glib.date_time.DateTime dt2)A comparison function for #GDateTimes that is suitable as a #GCompareFunc. Both #GDateTimes must be non-null.glib.types.TimeSpan difference(glib.date_time.DateTime begin)Calculates the difference in time between end and begin. The #GTimeSpan that is returned is effectively end - begin (ie: positive if the first parameter is larger).bool equal(glib.date_time.DateTime dt2)Checks to see if dt1 and dt2 are equal.string format(string format)Creates a newly allocated string representing the requested format.string formatIso8601()Format datetime in [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601), including the date, time and time zone, and return that as a UTF-8 encoded string.int getDayOfMonth()Retrieves the day of the month represented by datetime in the gregorian calendar. Returns: the day of the monthint getDayOfWeek()Retrieves the ISO 8601 day of the week on which datetime falls (1 is Monday, 2 is Tuesday... 7 is Sunday). Returns: the day of the weekint getDayOfYear()Retrieves the day of the year represented by datetime in the Gregorian calendar. Returns: the day of the yearint getHour()Retrieves the hour of the day represented by datetime Returns: the hour of the dayint getMicrosecond()Retrieves the microsecond of the date represented by datetime Returns: the microsecond of the secondint getMinute()Retrieves the minute of the hour represented by datetime Returns: the minute of the hourint getMonth()Retrieves the month of the year represented by datetime in the Gregorian calendar. Returns: the month represented by datetimeint getSecond()Retrieves the second of the minute represented by datetime Returns: the second represented by datetimedouble getSeconds()Retrieves the number of seconds since the start of the last minute, including the fractional part. Returns: the number of secondsglib.time_zone.TimeZone getTimezone()Get the time zone for this datetime. Returns: the time zonestring getTimezoneAbbreviation()Determines the time zone abbreviation to be used at the time and in the time zone of datetime.glib.types.TimeSpan getUtcOffset()Determines the offset to UTC in effect at the time and in the time zone of datetime.int getWeekNumberingYear()Returns the ISO 8601 week-numbering year in which the week containing datetime falls.int getWeekOfYear()Returns the ISO 8601 week number for the week containing datetime. The ISO 8601 week number is the same for every day of the week (from Moday through Sunday). That can produce some unusual results...int getYear()Retrieves the year represented by datetime in the Gregorian calendar. Returns: the year represented by datetimevoid getYmd(out int year, out int month, out int day)Retrieves the Gregorian day, month, and year of a given #GDateTime.uint hash()Hashes datetime into a #guint, suitable for use within #GHashTable. Returns: a #guint containing the hashbool isDaylightSavings()Determines if daylight savings time is in effect at the time and in the time zone of datetime. Returns: true if daylight savings time is in effectglib.date_time.DateTime toLocal()Creates a new #GDateTime corresponding to the same instant in time as datetime, but in the local time zone.bool toTimeval(glib.time_val.TimeVal tv)Stores the instant in time that datetime represents into tv.glib.date_time.DateTime toTimezone(glib.time_zone.TimeZone tz)Create a new #GDateTime corresponding to the same instant in time as datetime, but in the time zone tz.long toUnix()Gives the Unix time corresponding to datetime, rounding down to the nearest second.long toUnixUsec()Gives the Unix time corresponding to datetime, in microseconds.glib.date_time.DateTime toUtc()Creates a new #GDateTime corresponding to the same instant in time as datetime, but in UTC.this(glib.time_zone.TimeZone tz, int year, int month, int day, int hour, int minute, double seconds)Creates a new #GDateTime corresponding to the given date and time in the time zone tz.