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 module glib.TimeZone; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import glib.c.functions; 30 public import glib.c.types; 31 private import gtkd.Loader; 32 33 34 /** 35 * #GTimeZone is an opaque structure whose members cannot be accessed 36 * directly. 37 * 38 * Since: 2.26 39 */ 40 public class TimeZone 41 { 42 /** the main Gtk struct */ 43 protected GTimeZone* gTimeZone; 44 protected bool ownedRef; 45 46 /** Get the main Gtk struct */ 47 public GTimeZone* getTimeZoneStruct(bool transferOwnership = false) 48 { 49 if (transferOwnership) 50 ownedRef = false; 51 return gTimeZone; 52 } 53 54 /** the main Gtk struct as a void* */ 55 protected void* getStruct() 56 { 57 return cast(void*)gTimeZone; 58 } 59 60 /** 61 * Sets our main struct and passes it to the parent class. 62 */ 63 public this (GTimeZone* gTimeZone, bool ownedRef = false) 64 { 65 this.gTimeZone = gTimeZone; 66 this.ownedRef = ownedRef; 67 } 68 69 ~this () 70 { 71 if ( Linker.isLoaded(LIBRARY_GLIB) && ownedRef ) 72 g_time_zone_unref(gTimeZone); 73 } 74 75 76 /** 77 * A version of g_time_zone_new_identifier() which returns the UTC time zone 78 * if @identifier could not be parsed or loaded. 79 * 80 * If you need to check whether @identifier was loaded successfully, use 81 * g_time_zone_new_identifier(). 82 * 83 * Deprecated: Use g_time_zone_new_identifier() instead, as it provides 84 * error reporting. Change your code to handle a potentially %NULL return 85 * value. 86 * 87 * Params: 88 * identifier = a timezone identifier 89 * 90 * Returns: the requested timezone 91 * 92 * Since: 2.26 93 * 94 * Throws: ConstructionException GTK+ fails to create the object. 95 */ 96 public this(string identifier) 97 { 98 auto __p = g_time_zone_new(Str.toStringz(identifier)); 99 100 if(__p is null) 101 { 102 throw new ConstructionException("null returned by new"); 103 } 104 105 this(cast(GTimeZone*) __p); 106 } 107 108 /** 109 * Creates a #GTimeZone corresponding to the given constant offset from UTC, 110 * in seconds. 111 * 112 * This is equivalent to calling g_time_zone_new() with a string in the form 113 * `[+|-]hh[:mm[:ss]]`. 114 * 115 * Params: 116 * seconds = offset to UTC, in seconds 117 * 118 * Returns: a timezone at the given offset from UTC 119 * 120 * Since: 2.58 121 * 122 * Throws: ConstructionException GTK+ fails to create the object. 123 */ 124 public this(int seconds) 125 { 126 auto __p = g_time_zone_new_offset(seconds); 127 128 if(__p is null) 129 { 130 throw new ConstructionException("null returned by new_offset"); 131 } 132 133 this(cast(GTimeZone*) __p); 134 } 135 136 /** 137 * Finds an interval within @tz that corresponds to the given @time_, 138 * possibly adjusting @time_ if required to fit into an interval. 139 * The meaning of @time_ depends on @type. 140 * 141 * This function is similar to g_time_zone_find_interval(), with the 142 * difference that it always succeeds (by making the adjustments 143 * described below). 144 * 145 * In any of the cases where g_time_zone_find_interval() succeeds then 146 * this function returns the same value, without modifying @time_. 147 * 148 * This function may, however, modify @time_ in order to deal with 149 * non-existent times. If the non-existent local @time_ of 02:30 were 150 * requested on March 14th 2010 in Toronto then this function would 151 * adjust @time_ to be 03:00 and return the interval containing the 152 * adjusted time. 153 * 154 * Params: 155 * type = the #GTimeType of @time_ 156 * time = a pointer to a number of seconds since January 1, 1970 157 * 158 * Returns: the interval containing @time_, never -1 159 * 160 * Since: 2.26 161 */ 162 public int adjustTime(GTimeType type, long* time) 163 { 164 return g_time_zone_adjust_time(gTimeZone, type, time); 165 } 166 167 /** 168 * Finds an interval within @tz that corresponds to the given @time_. 169 * The meaning of @time_ depends on @type. 170 * 171 * If @type is %G_TIME_TYPE_UNIVERSAL then this function will always 172 * succeed (since universal time is monotonic and continuous). 173 * 174 * Otherwise @time_ is treated as local time. The distinction between 175 * %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in 176 * the case that the given @time_ is ambiguous. In Toronto, for example, 177 * 01:30 on November 7th 2010 occurred twice (once inside of daylight 178 * savings time and the next, an hour later, outside of daylight savings 179 * time). In this case, the different value of @type would result in a 180 * different interval being returned. 181 * 182 * It is still possible for this function to fail. In Toronto, for 183 * example, 02:00 on March 14th 2010 does not exist (due to the leap 184 * forward to begin daylight savings time). -1 is returned in that 185 * case. 186 * 187 * Params: 188 * type = the #GTimeType of @time_ 189 * time = a number of seconds since January 1, 1970 190 * 191 * Returns: the interval containing @time_, or -1 in case of failure 192 * 193 * Since: 2.26 194 */ 195 public int findInterval(GTimeType type, long time) 196 { 197 return g_time_zone_find_interval(gTimeZone, type, time); 198 } 199 200 /** 201 * Determines the time zone abbreviation to be used during a particular 202 * @interval of time in the time zone @tz. 203 * 204 * For example, in Toronto this is currently "EST" during the winter 205 * months and "EDT" during the summer months when daylight savings time 206 * is in effect. 207 * 208 * Params: 209 * interval = an interval within the timezone 210 * 211 * Returns: the time zone abbreviation, which belongs to @tz 212 * 213 * Since: 2.26 214 */ 215 public string getAbbreviation(int interval) 216 { 217 return Str.toString(g_time_zone_get_abbreviation(gTimeZone, interval)); 218 } 219 220 /** 221 * Get the identifier of this #GTimeZone, as passed to g_time_zone_new(). 222 * If the identifier passed at construction time was not recognised, `UTC` will 223 * be returned. If it was %NULL, the identifier of the local timezone at 224 * construction time will be returned. 225 * 226 * The identifier will be returned in the same format as provided at 227 * construction time: if provided as a time offset, that will be returned by 228 * this function. 229 * 230 * Returns: identifier for this timezone 231 * 232 * Since: 2.58 233 */ 234 public string getIdentifier() 235 { 236 return Str.toString(g_time_zone_get_identifier(gTimeZone)); 237 } 238 239 /** 240 * Determines the offset to UTC in effect during a particular @interval 241 * of time in the time zone @tz. 242 * 243 * The offset is the number of seconds that you add to UTC time to 244 * arrive at local time for @tz (ie: negative numbers for time zones 245 * west of GMT, positive numbers for east). 246 * 247 * Params: 248 * interval = an interval within the timezone 249 * 250 * Returns: the number of seconds that should be added to UTC to get the 251 * local time in @tz 252 * 253 * Since: 2.26 254 */ 255 public int getOffset(int interval) 256 { 257 return g_time_zone_get_offset(gTimeZone, interval); 258 } 259 260 /** 261 * Determines if daylight savings time is in effect during a particular 262 * @interval of time in the time zone @tz. 263 * 264 * Params: 265 * interval = an interval within the timezone 266 * 267 * Returns: %TRUE if daylight savings time is in effect 268 * 269 * Since: 2.26 270 */ 271 public bool isDst(int interval) 272 { 273 return g_time_zone_is_dst(gTimeZone, interval) != 0; 274 } 275 276 alias doref = ref_; 277 /** 278 * Increases the reference count on @tz. 279 * 280 * Returns: a new reference to @tz. 281 * 282 * Since: 2.26 283 */ 284 public TimeZone ref_() 285 { 286 auto __p = g_time_zone_ref(gTimeZone); 287 288 if(__p is null) 289 { 290 return null; 291 } 292 293 return new TimeZone(cast(GTimeZone*) __p, true); 294 } 295 296 /** 297 * Decreases the reference count on @tz. 298 * 299 * Since: 2.26 300 */ 301 public void unref() 302 { 303 g_time_zone_unref(gTimeZone); 304 } 305 }