DateTime

constructor()(source)

Creates a #GDateTime corresponding to this exact instant in UTC.

This is equivalent to calling g_date_time_new_now() with the time zone returned by g_time_zone_new_utc().

Return

a new #GDateTime, or null

Since

2.26


constructor(    tz: TimeZone,     year: <Error class: unknown class>,     month: <Error class: unknown class>,     day: <Error class: unknown class>,     hour: <Error class: unknown class>,     minute: <Error class: unknown class>,     seconds: <Error class: unknown class>)(source)

Creates a new #GDateTime corresponding to the given date and time in the time zone @tz.

The @year must be between 1 and 9999, @month between 1 and 12 and @day between 1 and 28, 29, 30 or 31 depending on the month and the year.

Return

a new #GDateTime, or null

Since

2.26

Parameters

tz

a #GTimeZone

year

the year component of the date

month

the month component of the date

day

the day component of the date

hour

the hour component of the date

minute

the minute component of the date

seconds

the number of seconds past the minute


constructor(text: String, defaultTz: TimeZone? = null)(source)

Creates a #GDateTime corresponding to the given ISO 8601 formatted string

Return

a new #GDateTime, or null

Since

2.56

Parameters

text

an ISO 8601 formatted time string.

defaultTz

a #GTimeZone to use if the text doesn't contain a timezone, or null.


constructor(tv: TimeVal)(source)

⚠️ Deprecated ⚠️

This is deprecated since version 2.62.

#GTimeVal is not year-2038-safe. Use g_date_time_new_from_unix_utc() instead.

Creates a #GDateTime corresponding to the given #GTimeVal @tv in UTC.

The time contained in a #GTimeVal is always stored in the form of seconds elapsed since 1970-01-01 00:00:00 UTC.

This call can fail (returning null) if @tv represents a time outside of the supported range of #GDateTime.

You should release the return value by calling g_date_time_unref() when you are done with it.

Return

a new #GDateTime, or null

Since

2.26

Parameters

tv

a #GTimeVal


constructor(t: <Error class: unknown class>)(source)

Creates a #GDateTime corresponding to the given Unix time @t in UTC.

Unix time is the number of seconds that have elapsed since 1970-01-01 00:00:00 UTC.

This call can fail (returning null) if @t represents a time outside of the supported range of #GDateTime.

You should release the return value by calling g_date_time_unref() when you are done with it.

Return

a new #GDateTime, or null

Since

2.26

Parameters

t

the Unix time


constructor(    year: <Error class: unknown class>,     month: <Error class: unknown class>,     day: <Error class: unknown class>,     hour: <Error class: unknown class>,     minute: <Error class: unknown class>,     seconds: <Error class: unknown class>)(source)

Creates a new #GDateTime corresponding to the given date and time in UTC.

This call is equivalent to calling g_date_time_new() with the time zone returned by g_time_zone_new_utc().

Return

a #GDateTime, or null

Since

2.26

Parameters

year

the year component of the date

month

the month component of the date

day

the day component of the date

hour

the hour component of the date

minute

the minute component of the date

seconds

the number of seconds past the minute


constructor(tz: TimeZone)(source)

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.

This function will always succeed unless GLib is still being used after the year 9999.

You should release the return value by calling g_date_time_unref() when you are done with it.

Return

a new #GDateTime, or null

Since

2.26

Parameters

tz

a #GTimeZone


constructor(glibDateTimePointer: <Error class: unknown class><<Error class: unknown class>>)(source)