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