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: No 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 * structWrap: 50 * - GTimeZone* -> TimeZone 51 * module aliases: 52 * local aliases: 53 * overrides: 54 */ 55 56 module glib.TimeZone; 57 58 public import gtkc.glibtypes; 59 60 private import gtkc.glib; 61 private import glib.ConstructionException; 62 63 64 private import glib.Str; 65 66 67 68 69 /** 70 * Description 71 * GTimeZone is a structure that represents a time zone, at no 72 * particular point in time. It is refcounted and immutable. 73 * A time zone contains a number of intervals. Each interval has 74 * an abbreviation to describe it, an offet to UTC and a flag indicating 75 * if the daylight savings time is in effect during that interval. A 76 * time zone always has at least one interval -- interval 0. 77 * Every UTC time is contained within exactly one interval, but a given 78 * local time may be contained within zero, one or two intervals (due to 79 * incontinuities associated with daylight savings time). 80 * An interval may refer to a specific period of time (eg: the duration 81 * of daylight savings time during 2010) or it may refer to many periods 82 * of time that share the same properties (eg: all periods of daylight 83 * savings time). It is also possible (usually for political reasons) 84 * that some properties (like the abbreviation) change between intervals 85 * without other properties changing. 86 * GTimeZone is available since GLib 2.26. 87 */ 88 public class TimeZone 89 { 90 91 /** the main Gtk struct */ 92 protected GTimeZone* gTimeZone; 93 94 95 public GTimeZone* getTimeZoneStruct() 96 { 97 return gTimeZone; 98 } 99 100 101 /** the main Gtk struct as a void* */ 102 protected void* getStruct() 103 { 104 return cast(void*)gTimeZone; 105 } 106 107 /** 108 * Sets our main struct and passes it to the parent class 109 */ 110 public this (GTimeZone* gTimeZone) 111 { 112 this.gTimeZone = gTimeZone; 113 } 114 115 /** 116 */ 117 118 /** 119 * Decreases the reference count on tz. 120 * Since 2.26 121 */ 122 public void unref() 123 { 124 // void g_time_zone_unref (GTimeZone *tz); 125 g_time_zone_unref(gTimeZone); 126 } 127 128 /** 129 * Increases the reference count on tz. 130 * Since 2.26 131 * Returns: a new reference to tz. 132 */ 133 public TimeZone doref() 134 { 135 // GTimeZone * g_time_zone_ref (GTimeZone *tz); 136 auto p = g_time_zone_ref(gTimeZone); 137 138 if(p is null) 139 { 140 return null; 141 } 142 143 return new TimeZone(cast(GTimeZone*) p); 144 } 145 146 /** 147 * Creates a GTimeZone corresponding to identifier. 148 * identifier can either be an RFC3339/ISO 8601 time offset or 149 * something that would pass as a valid value for the 150 * TZ environment variable (including NULL). 151 * Valid RFC3339 time offsets are "Z" (for UTC) or 152 * "±hh:mm". ISO 8601 additionally specifies 153 * "±hhmm" and "±hh". 154 * The TZ environment variable typically corresponds 155 * to the name of a file in the zoneinfo database, but there are many 156 * other possibilities. Note that those other possibilities are not 157 * currently implemented, but are planned. 158 * g_time_zone_new_local() calls this function with the value of the 159 * TZ environment variable. This function itself is 160 * independent of the value of TZ, but if identifier 161 * is NULL then /etc/localtime will be consulted 162 * to discover the correct timezone. 163 * See RFC3339 164 * §5.6 for a precise definition of valid RFC3339 time offsets 165 * (the time-offset expansion) and ISO 8601 for the 166 * full list of valid time offsets. See The 167 * GNU C Library manual for an explanation of the possible 168 * values of the TZ environment variable. 169 * You should release the return value by calling g_time_zone_unref() 170 * when you are done with it. 171 * Since 2.26 172 * Params: 173 * identifier = a timezone identifier. [allow-none] 174 * Throws: ConstructionException GTK+ fails to create the object. 175 */ 176 public this (string identifier) 177 { 178 // GTimeZone * g_time_zone_new (const gchar *identifier); 179 auto p = g_time_zone_new(Str.toStringz(identifier)); 180 if(p is null) 181 { 182 throw new ConstructionException("null returned by g_time_zone_new(Str.toStringz(identifier))"); 183 } 184 this(cast(GTimeZone*) p); 185 } 186 187 /** 188 * Finds an the interval within tz that corresponds to the given time. 189 * The meaning of time depends on type. 190 * If type is G_TIME_TYPE_UNIVERSAL then this function will always 191 * succeed (since universal time is monotonic and continuous). 192 * Otherwise time is treated is local time. The distinction between 193 * G_TIME_TYPE_STANDARD and G_TIME_TYPE_DAYLIGHT is ignored except in 194 * the case that the given time is ambiguous. In Toronto, for example, 195 * 01:30 on November 7th 2010 occured twice (once inside of daylight 196 * savings time and the next, an hour later, outside of daylight savings 197 * time). In this case, the different value of type would result in a 198 * different interval being returned. 199 * It is still possible for this function to fail. In Toronto, for 200 * example, 02:00 on March 14th 2010 does not exist (due to the leap 201 * forward to begin daylight savings time). -1 is returned in that 202 * case. 203 * Since 2.26 204 * Params: 205 * type = the GTimeType of time 206 * time = a number of seconds since January 1, 1970 207 * Returns: the interval containing time, or -1 in case of failure 208 */ 209 public int findInterval(GTimeType type, long time) 210 { 211 // gint g_time_zone_find_interval (GTimeZone *tz, GTimeType type, gint64 time); 212 return g_time_zone_find_interval(gTimeZone, type, time); 213 } 214 215 /** 216 * Finds an interval within tz that corresponds to the given time, 217 * possibly adjusting time if required to fit into an interval. 218 * The meaning of time depends on type. 219 * This function is similar to g_time_zone_find_interval(), with the 220 * difference that it always succeeds (by making the adjustments 221 * described below). 222 * In any of the cases where g_time_zone_find_interval() succeeds then 223 * this function returns the same value, without modifying time. 224 * This function may, however, modify time in order to deal with 225 * non-existent times. If the non-existent local time of 02:30 were 226 * requested on March 13th 2010 in Toronto then this function would 227 * adjust time to be 03:00 and return the interval containing the 228 * adjusted time. 229 * Since 2.26 230 * Params: 231 * type = the GTimeType of time 232 * time = a pointer to a number of seconds since January 1, 1970 233 * Returns: the interval containing time, never -1 234 */ 235 public int adjustTime(GTimeType type, ref long time) 236 { 237 // gint g_time_zone_adjust_time (GTimeZone *tz, GTimeType type, gint64 *time); 238 return g_time_zone_adjust_time(gTimeZone, type, &time); 239 } 240 241 /** 242 * Determines the time zone abbreviation to be used during a particular 243 * interval of time in the time zone tz. 244 * For example, in Toronto this is currently "EST" during the winter 245 * months and "EDT" during the summer months when daylight savings time 246 * is in effect. 247 * Since 2.26 248 * Params: 249 * interval = an interval within the timezone 250 * Returns: the time zone abbreviation, which belongs to tz 251 */ 252 public string getAbbreviation(int interval) 253 { 254 // const gchar * g_time_zone_get_abbreviation (GTimeZone *tz, gint interval); 255 return Str.toString(g_time_zone_get_abbreviation(gTimeZone, interval)); 256 } 257 258 /** 259 * Determines the offset to UTC in effect during a particular interval 260 * of time in the time zone tz. 261 * The offset is the number of seconds that you add to UTC time to 262 * arrive at local time for tz (ie: negative numbers for time zones 263 * west of GMT, positive numbers for east). 264 * Since 2.26 265 * Params: 266 * interval = an interval within the timezone 267 * Returns: the number of seconds that should be added to UTC to get the local time in tz 268 */ 269 public int getOffset(int interval) 270 { 271 // gint32 g_time_zone_get_offset (GTimeZone *tz, gint interval); 272 return g_time_zone_get_offset(gTimeZone, interval); 273 } 274 275 /** 276 * Determines if daylight savings time is in effect during a particular 277 * interval of time in the time zone tz. 278 * Since 2.26 279 * Params: 280 * interval = an interval within the timezone 281 * Returns: TRUE if daylight savings time is in effect 282 */ 283 public int isDst(int interval) 284 { 285 // gboolean g_time_zone_is_dst (GTimeZone *tz, gint interval); 286 return g_time_zone_is_dst(gTimeZone, interval); 287 } 288 }