TimeZone
Object Hierarchy:
Description:
[ Compact ]
[ Version ( since = "2.26" ) ]
[ CCode ( ref_function = "g_time_zone_ref" , type_id = "G_TYPE_TIME_ZONE" , unref_function = "g_time_zone_unref" ) ]
public class TimeZone
A `GTimeZone` represents a time zone, at no particular point in time.
The `GTimeZone` struct is refcounted and immutable.
Each time zone has an identifier (for example, ‘Europe/London’) which is platform dependent. See [ctor@GLib.TimeZone.new] for
information on the identifier formats. The identifier of a time zone can be retrieved using [method@GLib.TimeZone.get_identifier].
A time zone contains a number of intervals. Each interval has an abbreviation to describe it (for example, ‘PDT’), an offset to UTC
and a flag indicating if the daylight savings time is in effect during that interval. A time zone always has at least one interval —
interval 0. Note that interval abbreviations are not the same as time zone identifiers (apart from ‘UTC’), and cannot be passed to [
ctor@GLib.TimeZone.new].
Every UTC time is contained within exactly one interval, but a given local time may be contained within zero, one or two intervals (due
to incontinuities associated with daylight savings time).
An interval may refer to a specific period of time (eg: the duration of daylight savings time during 2010) or it may refer to many
periods of time that share the same properties (eg: all periods of daylight savings time). It is also possible (usually for political
reasons) that some properties (like the abbreviation) change between intervals without other properties changing.
Content:
Creation methods:
- public TimeZone (string identifier)
A version of TimeZone.new_identifier
which returns the UTC time zone if identifier could not be parsed or loaded.
- public TimeZone.identifier (string? identifier) throws Error
- public TimeZone.local ()
Creates a TimeZone corresponding to local
time.
- public TimeZone.offset (int32 seconds)
Creates a TimeZone corresponding to the
given constant offset from UTC, in seconds.
- public TimeZone.utc ()
Creates a TimeZone corresponding to UTC.
Methods:
- public int adjust_time (TimeType type, ref int64 time)
Finds an interval within this that
corresponds to the given time_, possibly adjusting time_ if required to fit into an interval.
- public int find_interval (TimeType type, int64 time)
Finds an interval within this that
corresponds to the given time_.
- public unowned string get_abbreviation (int interval)
Determines the time zone abbreviation to be used during a particular
interval of time in the time zone this.
- public unowned string get_identifier ()
Get the identifier of this TimeZone, as
passed to TimeZone.
- public int32 get_offset (int interval)
Determines the offset to UTC in effect during a particular
interval of time in the time zone this.
- public bool is_dst (int interval)
Determines if daylight savings time is in effect during a particular
interval of time in the time zone this.