DateTime

class DateTime(pointer: <Error class: unknown class><<Error class: unknown class>>) : ProxyInstance

GDateTime is a structure that combines a Gregorian date and time into a single structure.

GDateTime 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. GDateTime follows POSIX time in the sense that it is oblivious to leap seconds.

GDateTime is an immutable object; once it has been created it cannot be modified further. All modifiers will create a new GDateTime. Nearly all such functions can fail due to the date or time going out of range, in which case null will be returned.

GDateTime is reference counted: the reference count is increased by calling method@GLib.DateTime.ref and decreased by calling method@GLib.DateTime.unref. When the reference count drops to 0, the resources allocated by the GDateTime 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).

Skipped during bindings generation

  • parameter dt2: DateTime

  • parameter dt2: DateTime

  • parameter year: year: Out parameter is not supported

Since

2.26

Constructors

Link copied to clipboard
constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val glibDateTimePointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open override val handle: <Error class: unknown class>?

Functions

Link copied to clipboard
fun add(timespan: <Error class: unknown class>): DateTime?

Creates a copy of @datetime and adds the specified timespan to the copy.

Link copied to clipboard
fun addDays(days: <Error class: unknown class>): DateTime?

Creates a copy of @datetime and adds the specified number of days to the copy. Add negative values to subtract days.

Link copied to clipboard
fun addFull(years: <Error class: unknown class>, months: <Error class: unknown class>, days: <Error class: unknown class>, hours: <Error class: unknown class>, minutes: <Error class: unknown class>, seconds: <Error class: unknown class>): DateTime?

Creates a new #GDateTime adding the specified values to the current date and time in @datetime. Add negative values to subtract.

Link copied to clipboard
fun addHours(hours: <Error class: unknown class>): DateTime?

Creates a copy of @datetime and adds the specified number of hours. Add negative values to subtract hours.

Link copied to clipboard
fun addMinutes(minutes: <Error class: unknown class>): DateTime?

Creates a copy of @datetime adding the specified number of minutes. Add negative values to subtract minutes.

Link copied to clipboard
fun addMonths(months: <Error class: unknown class>): DateTime?

Creates a copy of @datetime and adds the specified number of months to the copy. Add negative values to subtract months.

Link copied to clipboard
fun addSeconds(seconds: <Error class: unknown class>): DateTime?

Creates a copy of @datetime and adds the specified number of seconds. Add negative values to subtract seconds.

Link copied to clipboard
fun addWeeks(weeks: <Error class: unknown class>): DateTime?

Creates a copy of @datetime and adds the specified number of weeks to the copy. Add negative values to subtract weeks.

Link copied to clipboard
fun addYears(years: <Error class: unknown class>): DateTime?

Creates a copy of @datetime and adds the specified number of years to the copy. Add negative values to subtract years.

Link copied to clipboard
fun difference(begin: DateTime): <Error class: unknown class>

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).

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Compare two proxy instances for equality. This will compare both the type of the instances, and their memory addresses.

Link copied to clipboard
fun format(format: String): String?

Creates a newly allocated string representing the requested @format.

Link copied to clipboard

Format @datetime in ISO 8601 format, including the date, time and time zone, and return that as a UTF-8 encoded string.

Link copied to clipboard
fun getDayOfMonth(): <Error class: unknown class>

Retrieves the day of the month represented by @datetime in the gregorian calendar.

Link copied to clipboard
fun getDayOfWeek(): <Error class: unknown class>

Retrieves the ISO 8601 day of the week on which @datetime falls (1 is Monday, 2 is Tuesday... 7 is Sunday).

Link copied to clipboard
fun getDayOfYear(): <Error class: unknown class>

Retrieves the day of the year represented by @datetime in the Gregorian calendar.

Link copied to clipboard
fun getHour(): <Error class: unknown class>

Retrieves the hour of the day represented by @datetime

Link copied to clipboard
fun getMicrosecond(): <Error class: unknown class>

Retrieves the microsecond of the date represented by @datetime

Link copied to clipboard
fun getMinute(): <Error class: unknown class>

Retrieves the minute of the hour represented by @datetime

Link copied to clipboard
fun getMonth(): <Error class: unknown class>

Retrieves the month of the year represented by @datetime in the Gregorian calendar.

Link copied to clipboard
fun getSecond(): <Error class: unknown class>

Retrieves the second of the minute represented by @datetime

Link copied to clipboard
fun getSeconds(): <Error class: unknown class>

Retrieves the number of seconds since the start of the last minute, including the fractional part.

Link copied to clipboard

Get the time zone for this @datetime.

Link copied to clipboard

Determines the time zone abbreviation to be used at the time and in the time zone of @datetime.

Link copied to clipboard
fun getUtcOffset(): <Error class: unknown class>

Determines the offset to UTC in effect at the time and in the time zone of @datetime.

Link copied to clipboard
fun getWeekNumberingYear(): <Error class: unknown class>

Returns the ISO 8601 week-numbering year in which the week containing

Link copied to clipboard
fun getWeekOfYear(): <Error class: unknown class>

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 (described below).

Link copied to clipboard
fun getYear(): <Error class: unknown class>

Retrieves the year represented by @datetime in the Gregorian calendar.

Link copied to clipboard
fun hash(): <Error class: unknown class>

Hashes @datetime into a #guint, suitable for use within #GHashTable.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Determines if daylight savings time is in effect at the time and in the time zone of @datetime.

Link copied to clipboard
fun ref(): DateTime

Atomically increments the reference count of @datetime by one.

Link copied to clipboard

Creates a new #GDateTime corresponding to the same instant in time as

Link copied to clipboard

Stores the instant in time that @datetime represents into @tv.

Link copied to clipboard

Create a new #GDateTime corresponding to the same instant in time as

Link copied to clipboard
fun toUnix(): <Error class: unknown class>

Gives the Unix time corresponding to @datetime, rounding down to the nearest second.

Link copied to clipboard
fun toUnixUsec(): <Error class: unknown class>

Gives the Unix time corresponding to @datetime, in microseconds.

Link copied to clipboard
fun toUtc(): DateTime?

Creates a new #GDateTime corresponding to the same instant in time as

Link copied to clipboard
fun unref()

Atomically decrements the reference count of @datetime by one.