1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = glib-GTimeZone.html
27  * outPack = glib
28  * outFile = TimeZone
29  * strct   = GTimeZone
30  * realStrct=
31  * ctorStrct=
32  * clss    = TimeZone
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_time_zone_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * 	- g_time_zone_new_local
45  * 	- g_time_zone_new_utc
46  * omit signals:
47  * imports:
48  * 	- glib.Str
49  * 	- gtkc.Loader
50  * 	- gtkc.paths
51  * structWrap:
52  * 	- GTimeZone* -> TimeZone
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module glib.TimeZone;
59 
60 public  import gtkc.glibtypes;
61 
62 private import gtkc.glib;
63 private import glib.ConstructionException;
64 
65 private import glib.Str;
66 private import gtkc.Loader;
67 private import gtkc.paths;
68 
69 
70 
71 /**
72  * GTimeZone is a structure that represents a time zone, at no
73  * particular point in time. It is refcounted and immutable.
74  *
75  * A time zone contains a number of intervals. Each interval has
76  * an abbreviation to describe it, an offet to UTC and a flag indicating
77  * if the daylight savings time is in effect during that interval. A
78  * time zone always has at least one interval -- interval 0.
79  *
80  * Every UTC time is contained within exactly one interval, but a given
81  * local time may be contained within zero, one or two intervals (due to
82  * incontinuities associated with daylight savings time).
83  *
84  * An interval may refer to a specific period of time (eg: the duration
85  * of daylight savings time during 2010) or it may refer to many periods
86  * of time that share the same properties (eg: all periods of daylight
87  * savings time). It is also possible (usually for political reasons)
88  * that some properties (like the abbreviation) change between intervals
89  * without other properties changing.
90  *
91  * GTimeZone is available since GLib 2.26.
92  */
93 public class TimeZone
94 {
95 	
96 	/** the main Gtk struct */
97 	protected GTimeZone* gTimeZone;
98 	
99 	
100 	/** Get the main Gtk struct */
101 	public GTimeZone* getTimeZoneStruct()
102 	{
103 		return gTimeZone;
104 	}
105 	
106 	
107 	/** the main Gtk struct as a void* */
108 	protected void* getStruct()
109 	{
110 		return cast(void*)gTimeZone;
111 	}
112 	
113 	/**
114 	 * Sets our main struct and passes it to the parent class
115 	 */
116 	public this (GTimeZone* gTimeZone)
117 	{
118 		this.gTimeZone = gTimeZone;
119 	}
120 	
121 	~this ()
122 	{
123 		if ( Linker.isLoaded(LIBRARY.GLIB) && gTimeZone !is null )
124 		{
125 			g_time_zone_unref(gTimeZone);
126 		}
127 	}
128 	
129 	/**
130 	 */
131 	
132 	/**
133 	 * Decreases the reference count on tz.
134 	 * Since 2.26
135 	 */
136 	public void unref()
137 	{
138 		// void g_time_zone_unref (GTimeZone *tz);
139 		g_time_zone_unref(gTimeZone);
140 	}
141 	
142 	/**
143 	 * Increases the reference count on tz.
144 	 * Since 2.26
145 	 * Returns: a new reference to tz.
146 	 */
147 	public TimeZone doref()
148 	{
149 		// GTimeZone * g_time_zone_ref (GTimeZone *tz);
150 		auto p = g_time_zone_ref(gTimeZone);
151 		
152 		if(p is null)
153 		{
154 			return null;
155 		}
156 		
157 		return new TimeZone(cast(GTimeZone*) p);
158 	}
159 	
160 	/**
161 	 * Creates a GTimeZone corresponding to identifier.
162 	 * identifier can either be an RFC3339/ISO 8601 time offset or
163 	 * something that would pass as a valid value for the
164 	 * TZ environment variable (including NULL).
165 	 * In Windows, identifier can also be the unlocalized name of a time
166 	 * zone for standard time, for example "Pacific Standard Time".
167 	 * Valid RFC3339 time offsets are "Z" (for UTC) or
168 	 * "±hh:mm". ISO 8601 additionally specifies
169 	 * "±hhmm" and "±hh". Offsets are
170 	 * time values to be added to Coordinated Universal Time (UTC) to get
171 	 * the local time.
172 	 * In Unix, the TZ environment variable typically
173 	 * corresponds to the name of a file in the zoneinfo database, or
174 	 * string in "std offset [dst [offset],start[/time],end[/time]]"
175 	 * (POSIX) format. There are no spaces in the specification. The
176 	 * name of standard and daylight savings time zone must be three or more
177 	 * alphabetic characters. Offsets are time values to be added to local
178 	 * time to get Coordinated Universal Time (UTC) and should be
179 	 * "[±]hh[[:]mm[:ss]]". Dates are either
180 	 * "Jn" (Julian day with n between 1 and 365, leap
181 	 * years not counted), "n" (zero-based Julian day
182 	 * with n between 0 and 365) or "Mm.w.d" (day d
183 	 * (0 <= d <= 6) of week w (1 <= w <= 5) of month m (1 <= m <= 12), day
184 	 * 0 is a Sunday). Times are in local wall clock time, the default is
185 	 * 02:00:00.
186 	 * In Windows, the "tzn[+|–]hh[:mm[:ss]][dzn]" format is used, but also
187 	 * accepts POSIX format. The Windows format uses US rules for all time
188 	 * zones; daylight savings time is 60 minutes behind the standard time
189 	 * with date and time of change taken from Pacific Standard Time.
190 	 * Offsets are time values to be added to the local time to get
191 	 * Coordinated Universal Time (UTC).
192 	 * g_time_zone_new_local() calls this function with the value of the
193 	 * TZ environment variable. This function itself is
194 	 * independent of the value of TZ, but if identifier
195 	 * is NULL then /etc/localtime will be consulted
196 	 * to discover the correct time zone on Unix and the registry will be
197 	 * consulted or GetTimeZoneInformation() will be used to get the local
198 	 * time zone on Windows.
199 	 * If intervals are not available, only time zone rules from
200 	 * TZ environment variable or other means, then they
201 	 * will be computed from year 1900 to 2037. If the maximum year for the
202 	 * rules is available and it is greater than 2037, then it will followed
203 	 * instead.
204 	 * See RFC3339
205 	 * §5.6 for a precise definition of valid RFC3339 time offsets
206 	 * (the time-offset expansion) and ISO 8601 for the
207 	 * full list of valid time offsets. See The
208 	 * GNU C Library manual for an explanation of the possible
209 	 * values of the TZ environment variable. See
210 	 * Microsoft Time Zone Index Values for the list of time zones
211 	 * on Windows.
212 	 * You should release the return value by calling g_time_zone_unref()
213 	 * when you are done with it.
214 	 * Since 2.26
215 	 * Params:
216 	 * identifier = a timezone identifier. [allow-none]
217 	 * Throws: ConstructionException GTK+ fails to create the object.
218 	 */
219 	public this (string identifier)
220 	{
221 		// GTimeZone * g_time_zone_new (const gchar *identifier);
222 		auto p = g_time_zone_new(Str.toStringz(identifier));
223 		if(p is null)
224 		{
225 			throw new ConstructionException("null returned by g_time_zone_new(Str.toStringz(identifier))");
226 		}
227 		this(cast(GTimeZone*) p);
228 	}
229 	
230 	/**
231 	 * Finds an the interval within tz that corresponds to the given time_.
232 	 * The meaning of time_ depends on type.
233 	 * If type is G_TIME_TYPE_UNIVERSAL then this function will always
234 	 * succeed (since universal time is monotonic and continuous).
235 	 * Otherwise time_ is treated is local time. The distinction between
236 	 * G_TIME_TYPE_STANDARD and G_TIME_TYPE_DAYLIGHT is ignored except in
237 	 * the case that the given time_ is ambiguous. In Toronto, for example,
238 	 * 01:30 on November 7th 2010 occurred twice (once inside of daylight
239 	 * savings time and the next, an hour later, outside of daylight savings
240 	 * time). In this case, the different value of type would result in a
241 	 * different interval being returned.
242 	 * It is still possible for this function to fail. In Toronto, for
243 	 * example, 02:00 on March 14th 2010 does not exist (due to the leap
244 	 * forward to begin daylight savings time). -1 is returned in that
245 	 * case.
246 	 * Since 2.26
247 	 * Params:
248 	 * type = the GTimeType of time_
249 	 * time = a number of seconds since January 1, 1970
250 	 * Returns: the interval containing time_, or -1 in case of failure
251 	 */
252 	public int findInterval(GTimeType type, long time)
253 	{
254 		// gint g_time_zone_find_interval (GTimeZone *tz,  GTimeType type,  gint64 time_);
255 		return g_time_zone_find_interval(gTimeZone, type, time);
256 	}
257 	
258 	/**
259 	 * Finds an interval within tz that corresponds to the given time_,
260 	 * possibly adjusting time_ if required to fit into an interval.
261 	 * The meaning of time_ depends on type.
262 	 * This function is similar to g_time_zone_find_interval(), with the
263 	 * difference that it always succeeds (by making the adjustments
264 	 * described below).
265 	 * In any of the cases where g_time_zone_find_interval() succeeds then
266 	 * this function returns the same value, without modifying time_.
267 	 * This function may, however, modify time_ in order to deal with
268 	 * non-existent times. If the non-existent local time_ of 02:30 were
269 	 * requested on March 14th 2010 in Toronto then this function would
270 	 * adjust time_ to be 03:00 and return the interval containing the
271 	 * adjusted time.
272 	 * Since 2.26
273 	 * Params:
274 	 * type = the GTimeType of time_
275 	 * time = a pointer to a number of seconds since January 1, 1970
276 	 * Returns: the interval containing time_, never -1
277 	 */
278 	public int adjustTime(GTimeType type, ref long time)
279 	{
280 		// gint g_time_zone_adjust_time (GTimeZone *tz,  GTimeType type,  gint64 *time_);
281 		return g_time_zone_adjust_time(gTimeZone, type, &time);
282 	}
283 	
284 	/**
285 	 * Determines the time zone abbreviation to be used during a particular
286 	 * interval of time in the time zone tz.
287 	 * For example, in Toronto this is currently "EST" during the winter
288 	 * months and "EDT" during the summer months when daylight savings time
289 	 * is in effect.
290 	 * Since 2.26
291 	 * Params:
292 	 * interval = an interval within the timezone
293 	 * Returns: the time zone abbreviation, which belongs to tz
294 	 */
295 	public string getAbbreviation(int interval)
296 	{
297 		// const gchar * g_time_zone_get_abbreviation (GTimeZone *tz,  gint interval);
298 		return Str.toString(g_time_zone_get_abbreviation(gTimeZone, interval));
299 	}
300 	
301 	/**
302 	 * Determines the offset to UTC in effect during a particular interval
303 	 * of time in the time zone tz.
304 	 * The offset is the number of seconds that you add to UTC time to
305 	 * arrive at local time for tz (ie: negative numbers for time zones
306 	 * west of GMT, positive numbers for east).
307 	 * Since 2.26
308 	 * Params:
309 	 * interval = an interval within the timezone
310 	 * Returns: the number of seconds that should be added to UTC to get the local time in tz
311 	 */
312 	public int getOffset(int interval)
313 	{
314 		// gint32 g_time_zone_get_offset (GTimeZone *tz,  gint interval);
315 		return g_time_zone_get_offset(gTimeZone, interval);
316 	}
317 	
318 	/**
319 	 * Determines if daylight savings time is in effect during a particular
320 	 * interval of time in the time zone tz.
321 	 * Since 2.26
322 	 * Params:
323 	 * interval = an interval within the timezone
324 	 * Returns: TRUE if daylight savings time is in effect
325 	 */
326 	public int isDst(int interval)
327 	{
328 		// gboolean g_time_zone_is_dst (GTimeZone *tz,  gint interval);
329 		return g_time_zone_is_dst(gTimeZone, interval);
330 	}
331 }