source: appstream-generator/build/girepo/glib/TimeZone.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 9.3 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module glib.TimeZone;
22
23private import gi.glib;
24public  import gi.glibtypes;
25private import glib.ConstructionException;
26private import glib.Str;
27
28
29/**
30 * #GTimeZone is an opaque structure whose members cannot be accessed
31 * directly.
32 *
33 * Since: 2.26
34 */
35public class TimeZone
36{
37        /** the main Gtk struct */
38        protected GTimeZone* gTimeZone;
39        protected bool ownedRef;
40
41        /** Get the main Gtk struct */
42        public GTimeZone* getTimeZoneStruct()
43        {
44                return gTimeZone;
45        }
46
47        /** the main Gtk struct as a void* */
48        protected void* getStruct()
49        {
50                return cast(void*)gTimeZone;
51        }
52
53        /**
54         * Sets our main struct and passes it to the parent class.
55         */
56        public this (GTimeZone* gTimeZone, bool ownedRef = false)
57        {
58                this.gTimeZone = gTimeZone;
59                this.ownedRef = ownedRef;
60        }
61
62
63        /**
64         * Creates a #GTimeZone corresponding to @identifier.
65         *
66         * @identifier can either be an RFC3339/ISO 8601 time offset or
67         * something that would pass as a valid value for the `TZ` environment
68         * variable (including %NULL).
69         *
70         * In Windows, @identifier can also be the unlocalized name of a time
71         * zone for standard time, for example "Pacific Standard Time".
72         *
73         * Valid RFC3339 time offsets are `"Z"` (for UTC) or
74         * `"±hh:mm"`.  ISO 8601 additionally specifies
75         * `"±hhmm"` and `"±hh"`.  Offsets are
76         * time values to be added to Coordinated Universal Time (UTC) to get
77         * the local time.
78         *
79         * In UNIX, the `TZ` environment variable typically corresponds
80         * to the name of a file in the zoneinfo database, or string in
81         * "std offset [dst [offset],start[/time],end[/time]]" (POSIX) format.
82         * There  are  no spaces in the specification. The name of standard
83         * and daylight savings time zone must be three or more alphabetic
84         * characters. Offsets are time values to be added to local time to
85         * get Coordinated Universal Time (UTC) and should be
86         * `"[±]hh[[:]mm[:ss]]"`.  Dates are either
87         * `"Jn"` (Julian day with n between 1 and 365, leap
88         * years not counted), `"n"` (zero-based Julian day
89         * with n between 0 and 365) or `"Mm.w.d"` (day d
90         * (0 <= d <= 6) of week w (1 <= w <= 5) of month m (1 <= m <= 12), day
91         * 0 is a Sunday).  Times are in local wall clock time, the default is
92         * 02:00:00.
93         *
94         * In Windows, the "tzn[+|–]hh[:mm[:ss]][dzn]" format is used, but also
95         * accepts POSIX format.  The Windows format uses US rules for all time
96         * zones; daylight savings time is 60 minutes behind the standard time
97         * with date and time of change taken from Pacific Standard Time.
98         * Offsets are time values to be added to the local time to get
99         * Coordinated Universal Time (UTC).
100         *
101         * g_time_zone_new_local() calls this function with the value of the
102         * `TZ` environment variable. This function itself is independent of
103         * the value of `TZ`, but if @identifier is %NULL then `/etc/localtime`
104         * will be consulted to discover the correct time zone on UNIX and the
105         * registry will be consulted or GetTimeZoneInformation() will be used
106         * to get the local time zone on Windows.
107         *
108         * If intervals are not available, only time zone rules from `TZ`
109         * environment variable or other means, then they will be computed
110         * from year 1900 to 2037.  If the maximum year for the rules is
111         * available and it is greater than 2037, then it will followed
112         * instead.
113         *
114         * See
115         * [RFC3339 §5.6](http://tools.ietf.org/html/rfc3339#section-5.6)
116         * for a precise definition of valid RFC3339 time offsets
117         * (the `time-offset` expansion) and ISO 8601 for the
118         * full list of valid time offsets.  See
119         * [The GNU C Library manual](http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html)
120         * for an explanation of the possible
121         * values of the `TZ` environment variable. See
122         * [Microsoft Time Zone Index Values](http://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx)
123         * for the list of time zones on Windows.
124         *
125         * You should release the return value by calling g_time_zone_unref()
126         * when you are done with it.
127         *
128         * Params:
129         *     identifier = a timezone identifier
130         *
131         * Returns: the requested timezone
132         *
133         * Since: 2.26
134         *
135         * Throws: ConstructionException GTK+ fails to create the object.
136         */
137        public this(string identifier)
138        {
139                auto p = g_time_zone_new(Str.toStringz(identifier));
140               
141                if(p is null)
142                {
143                        throw new ConstructionException("null returned by new");
144                }
145               
146                this(cast(GTimeZone*) p);
147        }
148
149        /**
150         * Finds an interval within @tz that corresponds to the given @time_,
151         * possibly adjusting @time_ if required to fit into an interval.
152         * The meaning of @time_ depends on @type.
153         *
154         * This function is similar to g_time_zone_find_interval(), with the
155         * difference that it always succeeds (by making the adjustments
156         * described below).
157         *
158         * In any of the cases where g_time_zone_find_interval() succeeds then
159         * this function returns the same value, without modifying @time_.
160         *
161         * This function may, however, modify @time_ in order to deal with
162         * non-existent times.  If the non-existent local @time_ of 02:30 were
163         * requested on March 14th 2010 in Toronto then this function would
164         * adjust @time_ to be 03:00 and return the interval containing the
165         * adjusted time.
166         *
167         * Params:
168         *     type = the #GTimeType of @time_
169         *     time = a pointer to a number of seconds since January 1, 1970
170         *
171         * Returns: the interval containing @time_, never -1
172         *
173         * Since: 2.26
174         */
175        public int adjustTime(GTimeType type, long* time)
176        {
177                return g_time_zone_adjust_time(gTimeZone, type, time);
178        }
179
180        /**
181         * Finds an the interval within @tz that corresponds to the given @time_.
182         * The meaning of @time_ depends on @type.
183         *
184         * If @type is %G_TIME_TYPE_UNIVERSAL then this function will always
185         * succeed (since universal time is monotonic and continuous).
186         *
187         * Otherwise @time_ is treated as local time.  The distinction between
188         * %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in
189         * the case that the given @time_ is ambiguous.  In Toronto, for example,
190         * 01:30 on November 7th 2010 occurred twice (once inside of daylight
191         * savings time and the next, an hour later, outside of daylight savings
192         * time).  In this case, the different value of @type would result in a
193         * different interval being returned.
194         *
195         * It is still possible for this function to fail.  In Toronto, for
196         * example, 02:00 on March 14th 2010 does not exist (due to the leap
197         * forward to begin daylight savings time).  -1 is returned in that
198         * case.
199         *
200         * Params:
201         *     type = the #GTimeType of @time_
202         *     time = a number of seconds since January 1, 1970
203         *
204         * Returns: the interval containing @time_, or -1 in case of failure
205         *
206         * Since: 2.26
207         */
208        public int findInterval(GTimeType type, long time)
209        {
210                return g_time_zone_find_interval(gTimeZone, type, time);
211        }
212
213        /**
214         * Determines the time zone abbreviation to be used during a particular
215         * @interval of time in the time zone @tz.
216         *
217         * For example, in Toronto this is currently "EST" during the winter
218         * months and "EDT" during the summer months when daylight savings time
219         * is in effect.
220         *
221         * Params:
222         *     interval = an interval within the timezone
223         *
224         * Returns: the time zone abbreviation, which belongs to @tz
225         *
226         * Since: 2.26
227         */
228        public string getAbbreviation(int interval)
229        {
230                return Str.toString(g_time_zone_get_abbreviation(gTimeZone, interval));
231        }
232
233        /**
234         * Determines the offset to UTC in effect during a particular @interval
235         * of time in the time zone @tz.
236         *
237         * The offset is the number of seconds that you add to UTC time to
238         * arrive at local time for @tz (ie: negative numbers for time zones
239         * west of GMT, positive numbers for east).
240         *
241         * Params:
242         *     interval = an interval within the timezone
243         *
244         * Returns: the number of seconds that should be added to UTC to get the
245         *     local time in @tz
246         *
247         * Since: 2.26
248         */
249        public int getOffset(int interval)
250        {
251                return g_time_zone_get_offset(gTimeZone, interval);
252        }
253
254        /**
255         * Determines if daylight savings time is in effect during a particular
256         * @interval of time in the time zone @tz.
257         *
258         * Params:
259         *     interval = an interval within the timezone
260         *
261         * Returns: %TRUE if daylight savings time is in effect
262         *
263         * Since: 2.26
264         */
265        public bool isDst(int interval)
266        {
267                return g_time_zone_is_dst(gTimeZone, interval) != 0;
268        }
269
270        /**
271         * Increases the reference count on @tz.
272         *
273         * Returns: a new reference to @tz.
274         *
275         * Since: 2.26
276         */
277        public TimeZone doref()
278        {
279                auto p = g_time_zone_ref(gTimeZone);
280               
281                if(p is null)
282                {
283                        return null;
284                }
285               
286                return new TimeZone(cast(GTimeZone*) p, true);
287        }
288
289        /**
290         * Decreases the reference count on @tz.
291         *
292         * Since: 2.26
293         */
294        public void unref()
295        {
296                g_time_zone_unref(gTimeZone);
297        }
298}
Note: See TracBrowser for help on using the repository browser.