1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/gobject/types"
12)
13
14// A `GTimeZone` represents a time zone, at no particular point in time.
15//
16// The `GTimeZone` struct is refcounted and immutable.
17//
18// Each time zone has an identifier (for example, ‘Europe/London’) which is
19// platform dependent. See [ctor@GLib.TimeZone.new] for information on the
20// identifier formats. The identifier of a time zone can be retrieved using
21// [method@GLib.TimeZone.get_identifier].
22//
23// A time zone contains a number of intervals. Each interval has an abbreviation
24// to describe it (for example, ‘PDT’), an offset to UTC and a flag indicating
25// if the daylight savings time is in effect during that interval. A time zone
26// always has at least one interval — interval 0. Note that interval abbreviations
27// are not the same as time zone identifiers (apart from ‘UTC’), and cannot be
28// passed to [ctor@GLib.TimeZone.new].
29//
30// Every UTC time is contained within exactly one interval, but a given
31// local time may be contained within zero, one or two intervals (due to
32// incontinuities associated with daylight savings time).
33//
34// An interval may refer to a specific period of time (eg: the duration
35// of daylight savings time during 2010) or it may refer to many periods
36// of time that share the same properties (eg: all periods of daylight
37// savings time). It is also possible (usually for political reasons)
38// that some properties (like the abbreviation) change between intervals
39// without other properties changing.
40type TimeZone struct {
41 _ structs.HostLayout
42}
43
44var xTimeZoneGLibType func() types.GType
45
46func TimeZoneGLibType() types.GType {
47 return xTimeZoneGLibType()
48}
49
50func (x *TimeZone) GoPointer() uintptr {
51 return uintptr(unsafe.Pointer(x))
52}
53
54var xNewTimeZone func(uintptr) *TimeZone
55
56// A version of g_time_zone_new_identifier() which returns the UTC time zone
57// if @identifier could not be parsed or loaded.
58//
59// If you need to check whether @identifier was loaded successfully, use
60// g_time_zone_new_identifier().
61func NewTimeZone(IdentifierVar *string) *TimeZone {
62
63 IdentifierVarPtr := core.GStrdupNullable(IdentifierVar)
64 defer core.GFreeNullable(IdentifierVarPtr)
65
66 cret := xNewTimeZone(IdentifierVarPtr)
67 return cret
68}
69
70var xNewTimeZoneIdentifier func(uintptr) *TimeZone
71
72// Creates a #GTimeZone corresponding to @identifier. If @identifier cannot be
73// parsed or loaded, %NULL is returned.
74//
75// @identifier can either be an RFC3339/ISO 8601 time offset or
76// something that would pass as a valid value for the `TZ` environment
77// variable (including %NULL).
78//
79// In Windows, @identifier can also be the unlocalized name of a time
80// zone for standard time, for example "Pacific Standard Time".
81//
82// Valid RFC3339 time offsets are `"Z"` (for UTC) or
83// `"±hh:mm"`. ISO 8601 additionally specifies
84// `"±hhmm"` and `"±hh"`. Offsets are
85// time values to be added to Coordinated Universal Time (UTC) to get
86// the local time.
87//
88// In UNIX, the `TZ` environment variable typically corresponds
89// to the name of a file in the zoneinfo database, an absolute path to a file
90// somewhere else, or a string in
91// "std offset [dst [offset],start[/time],end[/time]]" (POSIX) format.
92// There are no spaces in the specification. The name of standard
93// and daylight savings time zone must be three or more alphabetic
94// characters. Offsets are time values to be added to local time to
95// get Coordinated Universal Time (UTC) and should be
96// `"[±]hh[[:]mm[:ss]]"`. Dates are either
97// `"Jn"` (Julian day with n between 1 and 365, leap
98// years not counted), `"n"` (zero-based Julian day
99// with n between 0 and 365) or `"Mm.w.d"` (day d
100// (0 <= d <= 6) of week w (1 <= w <= 5) of month m (1 <= m <= 12), day
101// 0 is a Sunday). Times are in local wall clock time, the default is
102// 02:00:00.
103//
104// In Windows, the "tzn[+|–]hh[:mm[:ss]][dzn]" format is used, but also
105// accepts POSIX format. The Windows format uses US rules for all time
106// zones; daylight savings time is 60 minutes behind the standard time
107// with date and time of change taken from Pacific Standard Time.
108// Offsets are time values to be added to the local time to get
109// Coordinated Universal Time (UTC).
110//
111// g_time_zone_new_local() calls this function with the value of the
112// `TZ` environment variable. This function itself is independent of
113// the value of `TZ`, but if @identifier is %NULL then `/etc/localtime`
114// will be consulted to discover the correct time zone on UNIX and the
115// registry will be consulted or GetTimeZoneInformation() will be used
116// to get the local time zone on Windows.
117//
118// If intervals are not available, only time zone rules from `TZ`
119// environment variable or other means, then they will be computed
120// from year 1900 to 2037. If the maximum year for the rules is
121// available and it is greater than 2037, then it will followed
122// instead.
123//
124// See
125// [RFC3339 §5.6](http://tools.ietf.org/html/rfc3339#section-5.6)
126// for a precise definition of valid RFC3339 time offsets
127// (the `time-offset` expansion) and ISO 8601 for the
128// full list of valid time offsets. See
129// [The GNU C Library manual](http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html)
130// for an explanation of the possible
131// values of the `TZ` environment variable. See
132// [Microsoft Time Zone Index Values](http://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx)
133// for the list of time zones on Windows.
134//
135// You should release the return value by calling g_time_zone_unref()
136// when you are done with it.
137func NewTimeZoneIdentifier(IdentifierVar *string) *TimeZone {
138
139 IdentifierVarPtr := core.GStrdupNullable(IdentifierVar)
140 defer core.GFreeNullable(IdentifierVarPtr)
141
142 cret := xNewTimeZoneIdentifier(IdentifierVarPtr)
143 return cret
144}
145
146var xNewTimeZoneLocal func() *TimeZone
147
148// Creates a #GTimeZone corresponding to local time. The local time
149// zone may change between invocations to this function; for example,
150// if the system administrator changes it.
151//
152// This is equivalent to calling g_time_zone_new() with the value of
153// the `TZ` environment variable (including the possibility of %NULL).
154//
155// You should release the return value by calling g_time_zone_unref()
156// when you are done with it.
157func NewTimeZoneLocal() *TimeZone {
158
159 cret := xNewTimeZoneLocal()
160 return cret
161}
162
163var xNewTimeZoneOffset func(int32) *TimeZone
164
165// Creates a #GTimeZone corresponding to the given constant offset from UTC,
166// in seconds.
167//
168// This is equivalent to calling g_time_zone_new() with a string in the form
169// `[+|-]hh[:mm[:ss]]`.
170//
171// It is possible for this function to fail if @seconds is too big (greater than
172// 24 hours), in which case this function will return the UTC timezone for
173// backwards compatibility. To detect failures like this, use
174// g_time_zone_new_identifier() directly.
175func NewTimeZoneOffset(SecondsVar int32) *TimeZone {
176
177 cret := xNewTimeZoneOffset(SecondsVar)
178 return cret
179}
180
181var xNewTimeZoneUtc func() *TimeZone
182
183// Creates a #GTimeZone corresponding to UTC.
184//
185// This is equivalent to calling g_time_zone_new() with a value like
186// "Z", "UTC", "+00", etc.
187//
188// You should release the return value by calling g_time_zone_unref()
189// when you are done with it.
190func NewTimeZoneUtc() *TimeZone {
191
192 cret := xNewTimeZoneUtc()
193 return cret
194}
195
196var xTimeZoneAdjustTime func(uintptr, TimeType, int64) int
197
198// Finds an interval within @tz that corresponds to the given @time_,
199// possibly adjusting @time_ if required to fit into an interval.
200// The meaning of @time_ depends on @type.
201//
202// This function is similar to g_time_zone_find_interval(), with the
203// difference that it always succeeds (by making the adjustments
204// described below).
205//
206// In any of the cases where g_time_zone_find_interval() succeeds then
207// this function returns the same value, without modifying @time_.
208//
209// This function may, however, modify @time_ in order to deal with
210// non-existent times. If the non-existent local @time_ of 02:30 were
211// requested on March 14th 2010 in Toronto then this function would
212// adjust @time_ to be 03:00 and return the interval containing the
213// adjusted time.
214func (x *TimeZone) AdjustTime(TypeVar TimeType, TimeVar int64) int {
215
216 cret := xTimeZoneAdjustTime(x.GoPointer(), TypeVar, TimeVar)
217 return cret
218}
219
220var xTimeZoneFindInterval func(uintptr, TimeType, int64) int
221
222// Finds an interval within @tz that corresponds to the given @time_.
223// The meaning of @time_ depends on @type.
224//
225// If @type is %G_TIME_TYPE_UNIVERSAL then this function will always
226// succeed (since universal time is monotonic and continuous).
227//
228// Otherwise @time_ is treated as local time. The distinction between
229// %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in
230// the case that the given @time_ is ambiguous. In Toronto, for example,
231// 01:30 on November 7th 2010 occurred twice (once inside of daylight
232// savings time and the next, an hour later, outside of daylight savings
233// time). In this case, the different value of @type would result in a
234// different interval being returned.
235//
236// It is still possible for this function to fail. In Toronto, for
237// example, 02:00 on March 14th 2010 does not exist (due to the leap
238// forward to begin daylight savings time). -1 is returned in that
239// case.
240func (x *TimeZone) FindInterval(TypeVar TimeType, TimeVar int64) int {
241
242 cret := xTimeZoneFindInterval(x.GoPointer(), TypeVar, TimeVar)
243 return cret
244}
245
246var xTimeZoneGetAbbreviation func(uintptr, int) string
247
248// Determines the time zone abbreviation to be used during a particular
249// @interval of time in the time zone @tz.
250//
251// For example, in Toronto this is currently "EST" during the winter
252// months and "EDT" during the summer months when daylight savings time
253// is in effect.
254func (x *TimeZone) GetAbbreviation(IntervalVar int) string {
255
256 cret := xTimeZoneGetAbbreviation(x.GoPointer(), IntervalVar)
257 return cret
258}
259
260var xTimeZoneGetIdentifier func(uintptr) string
261
262// Get the identifier of this #GTimeZone, as passed to g_time_zone_new().
263// If the identifier passed at construction time was not recognised, `UTC` will
264// be returned. If it was %NULL, the identifier of the local timezone at
265// construction time will be returned.
266//
267// The identifier will be returned in the same format as provided at
268// construction time: if provided as a time offset, that will be returned by
269// this function.
270func (x *TimeZone) GetIdentifier() string {
271
272 cret := xTimeZoneGetIdentifier(x.GoPointer())
273 return cret
274}
275
276var xTimeZoneGetOffset func(uintptr, int) int32
277
278// Determines the offset to UTC in effect during a particular @interval
279// of time in the time zone @tz.
280//
281// The offset is the number of seconds that you add to UTC time to
282// arrive at local time for @tz (ie: negative numbers for time zones
283// west of GMT, positive numbers for east).
284func (x *TimeZone) GetOffset(IntervalVar int) int32 {
285
286 cret := xTimeZoneGetOffset(x.GoPointer(), IntervalVar)
287 return cret
288}
289
290var xTimeZoneIsDst func(uintptr, int) bool
291
292// Determines if daylight savings time is in effect during a particular
293// @interval of time in the time zone @tz.
294func (x *TimeZone) IsDst(IntervalVar int) bool {
295
296 cret := xTimeZoneIsDst(x.GoPointer(), IntervalVar)
297 return cret
298}
299
300var xTimeZoneRef func(uintptr) *TimeZone
301
302// Increases the reference count on @tz.
303func (x *TimeZone) Ref() *TimeZone {
304
305 cret := xTimeZoneRef(x.GoPointer())
306 return cret
307}
308
309var xTimeZoneUnref func(uintptr)
310
311// Decreases the reference count on @tz.
312func (x *TimeZone) Unref() {
313
314 xTimeZoneUnref(x.GoPointer())
315
316}
317
318// Disambiguates a given time in two ways.
319//
320// First, specifies if the given time is in universal or local time.
321//
322// Second, if the time is in local time, specifies if it is local
323// standard time or local daylight time. This is important for the case
324// where the same local time occurs twice (during daylight savings time
325// transitions, for example).
326type TimeType int
327
328const (
329
330 // the time is in local standard time
331 GTimeTypeStandardValue TimeType = 0
332 // the time is in local daylight time
333 GTimeTypeDaylightValue TimeType = 1
334 // the time is in UTC
335 GTimeTypeUniversalValue TimeType = 2
336)
337
338func init() {
339 core.SetPackageName("GLIB", "glib-2.0")
340 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
341 var libs []uintptr
342 for _, libPath := range core.GetPaths("GLIB") {
343 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
344 if err != nil {
345 panic(err)
346 }
347 libs = append(libs, lib)
348 }
349
350 core.PuregoSafeRegister(&xTimeZoneGLibType, libs, "g_time_zone_get_type")
351
352 core.PuregoSafeRegister(&xNewTimeZone, libs, "g_time_zone_new")
353 core.PuregoSafeRegister(&xNewTimeZoneIdentifier, libs, "g_time_zone_new_identifier")
354 core.PuregoSafeRegister(&xNewTimeZoneLocal, libs, "g_time_zone_new_local")
355 core.PuregoSafeRegister(&xNewTimeZoneOffset, libs, "g_time_zone_new_offset")
356 core.PuregoSafeRegister(&xNewTimeZoneUtc, libs, "g_time_zone_new_utc")
357
358 core.PuregoSafeRegister(&xTimeZoneAdjustTime, libs, "g_time_zone_adjust_time")
359 core.PuregoSafeRegister(&xTimeZoneFindInterval, libs, "g_time_zone_find_interval")
360 core.PuregoSafeRegister(&xTimeZoneGetAbbreviation, libs, "g_time_zone_get_abbreviation")
361 core.PuregoSafeRegister(&xTimeZoneGetIdentifier, libs, "g_time_zone_get_identifier")
362 core.PuregoSafeRegister(&xTimeZoneGetOffset, libs, "g_time_zone_get_offset")
363 core.PuregoSafeRegister(&xTimeZoneIsDst, libs, "g_time_zone_is_dst")
364 core.PuregoSafeRegister(&xTimeZoneRef, libs, "g_time_zone_ref")
365 core.PuregoSafeRegister(&xTimeZoneUnref, libs, "g_time_zone_unref")
366
367}