1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY!
2
3
4 #include <glibmm.h>
5
6 #include <glibmm/datetime.h>
7 #include <glibmm/private/datetime_p.h>
8
9
10 /* Copyright (C) 2011 The glibmm Development Team
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26 #include <glibmm/utility.h>
27 #include <glibmm/timeval.h>
28 #include <glibmm/wrap.h>
29
30 namespace Glib
31 {
32
operator bool() const33 DateTime::operator bool() const
34 {
35 return (gobject_ != nullptr);
36 }
37
38 // Glib::Value<Glib::DateTime>
value_type()39 GType Value<DateTime>::value_type()
40 {
41 return G_TYPE_DATE_TIME;
42 }
43
set(const CppType & data)44 void Value<DateTime>::set(const CppType& data)
45 {
46 set_boxed(data.gobj());
47 }
48
get() const49 Value<DateTime>::CppType Value<DateTime>::get() const
50 {
51 return Glib::wrap(static_cast<CType>(get_boxed()), true);
52 }
53
54 } // namespace Glib
55
56 namespace
57 {
58 } // anonymous namespace
59
60
61 namespace Glib
62 {
63
wrap(GDateTime * object,bool take_copy)64 Glib::DateTime wrap(GDateTime* object, bool take_copy /* = false */)
65 {
66 return Glib::DateTime(object, take_copy);
67 }
68
69 } // namespace Glib
70
71
72 namespace Glib
73 {
74
75
DateTime()76 DateTime::DateTime()
77 :
78 gobject_ (nullptr) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
79 {}
80
DateTime(const DateTime & src)81 DateTime::DateTime(const DateTime& src)
82 :
83 gobject_ ((src.gobject_) ? g_date_time_ref(src.gobject_) : nullptr)
84 {}
85
DateTime(GDateTime * castitem,bool make_a_copy)86 DateTime::DateTime(GDateTime* castitem, bool make_a_copy /* = false */)
87 {
88 if(!make_a_copy)
89 {
90 // It was given to us by a function which has already made a copy for us to keep.
91 gobject_ = castitem;
92 }
93 else
94 {
95 // We are probably getting it via direct access to a struct,
96 // so we can not just take it - we have to take a copy of it.
97 if(castitem)
98 gobject_ = g_date_time_ref(castitem);
99 else
100 gobject_ = nullptr;
101 }
102 }
103
104
operator =(const DateTime & src)105 DateTime& DateTime::operator=(const DateTime& src)
106 {
107 const auto new_gobject = (src.gobject_) ? g_date_time_ref(src.gobject_) : nullptr;
108
109 if(gobject_)
110 g_date_time_unref(gobject_);
111
112 gobject_ = new_gobject;
113
114 return *this;
115 }
116
DateTime(DateTime && other)117 DateTime::DateTime(DateTime&& other) noexcept
118 :
119 gobject_(other.gobject_)
120 {
121 other.gobject_ = nullptr;
122 }
123
operator =(DateTime && other)124 DateTime& DateTime::operator=(DateTime&& other) noexcept
125 {
126 DateTime temp (other);
127 swap(temp);
128 return *this;
129 }
130
~DateTime()131 DateTime::~DateTime() noexcept
132 {
133 if(gobject_)
134 g_date_time_unref(gobject_);
135 }
136
swap(DateTime & other)137 void DateTime::swap(DateTime& other) noexcept
138 {
139 std::swap(gobject_, other.gobject_);
140 }
141
gobj_copy() const142 GDateTime* DateTime::gobj_copy() const
143 {
144 return g_date_time_ref(gobject_);
145 }
146
147
create_now(const TimeZone & tz)148 DateTime DateTime::create_now(const TimeZone& tz)
149 {
150 return Glib::wrap(g_date_time_new_now(const_cast<GTimeZone*>(tz.gobj())));
151 }
152
create_now_local()153 DateTime DateTime::create_now_local()
154 {
155 return Glib::wrap(g_date_time_new_now_local());
156 }
157
create_now_utc()158 DateTime DateTime::create_now_utc()
159 {
160 return Glib::wrap(g_date_time_new_now_utc());
161 }
162
create_now_local(gint64 t)163 DateTime DateTime::create_now_local(gint64 t)
164 {
165 return Glib::wrap(g_date_time_new_from_unix_local(t));
166 }
167
create_now_utc(gint64 t)168 DateTime DateTime::create_now_utc(gint64 t)
169 {
170 return Glib::wrap(g_date_time_new_from_unix_utc(t));
171 }
172
173 #ifndef GLIBMM_DISABLE_DEPRECATED
174 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
create_now_local(const TimeVal & tv)175 DateTime DateTime::create_now_local(const TimeVal& tv)
176 {
177 return Glib::wrap(g_date_time_new_from_timeval_local(&(tv)));
178 }
179 G_GNUC_END_IGNORE_DEPRECATIONS
180 #endif // GLIBMM_DISABLE_DEPRECATED
181
182 #ifndef GLIBMM_DISABLE_DEPRECATED
183 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
create_now_utc(const TimeVal & tv)184 DateTime DateTime::create_now_utc(const TimeVal& tv)
185 {
186 return Glib::wrap(g_date_time_new_from_timeval_utc(&(tv)));
187 }
188 G_GNUC_END_IGNORE_DEPRECATIONS
189 #endif // GLIBMM_DISABLE_DEPRECATED
190
create_from_iso8601(const Glib::ustring & text,const TimeZone & default_tz)191 DateTime DateTime::create_from_iso8601(const Glib::ustring& text, const TimeZone& default_tz)
192 {
193 return Glib::wrap(g_date_time_new_from_iso8601(text.c_str(), const_cast<GTimeZone*>(default_tz.gobj())));
194 }
195
create_from_iso8601(const Glib::ustring & text)196 DateTime DateTime::create_from_iso8601(const Glib::ustring& text)
197 {
198 return Glib::wrap(g_date_time_new_from_iso8601(text.c_str(), nullptr));
199 }
200
create(const TimeZone & tz,int year,int month,int day,int hour,int minute,double seconds)201 DateTime DateTime::create(const TimeZone& tz, int year, int month, int day, int hour, int minute, double seconds)
202 {
203 return Glib::wrap(g_date_time_new(const_cast<GTimeZone*>(tz.gobj()), year, month, day, hour, minute, seconds));
204 }
205
create_local(int year,int month,int day,int hour,int minute,double seconds)206 DateTime DateTime::create_local(int year, int month, int day, int hour, int minute, double seconds)
207 {
208 return Glib::wrap(g_date_time_new_local(year, month, day, hour, minute, seconds));
209 }
210
create_utc(int year,int month,int day,int hour,int minute,double seconds)211 DateTime DateTime::create_utc(int year, int month, int day, int hour, int minute, double seconds)
212 {
213 return Glib::wrap(g_date_time_new_utc(year, month, day, hour, minute, seconds));
214 }
215
add(TimeSpan timespan) const216 DateTime DateTime::add(TimeSpan timespan) const
217 {
218 return Glib::wrap(g_date_time_add(const_cast<GDateTime*>(gobj()), timespan));
219 }
220
add_years(int years) const221 DateTime DateTime::add_years(int years) const
222 {
223 return Glib::wrap(g_date_time_add_years(const_cast<GDateTime*>(gobj()), years));
224 }
225
add_months(int months) const226 DateTime DateTime::add_months(int months) const
227 {
228 return Glib::wrap(g_date_time_add_months(const_cast<GDateTime*>(gobj()), months));
229 }
230
add_weeks(int weeks) const231 DateTime DateTime::add_weeks(int weeks) const
232 {
233 return Glib::wrap(g_date_time_add_weeks(const_cast<GDateTime*>(gobj()), weeks));
234 }
235
add_days(int days) const236 DateTime DateTime::add_days(int days) const
237 {
238 return Glib::wrap(g_date_time_add_days(const_cast<GDateTime*>(gobj()), days));
239 }
240
add_hours(int hours) const241 DateTime DateTime::add_hours(int hours) const
242 {
243 return Glib::wrap(g_date_time_add_hours(const_cast<GDateTime*>(gobj()), hours));
244 }
245
add_minutes(int minutes) const246 DateTime DateTime::add_minutes(int minutes) const
247 {
248 return Glib::wrap(g_date_time_add_minutes(const_cast<GDateTime*>(gobj()), minutes));
249 }
250
add_seconds(double seconds) const251 DateTime DateTime::add_seconds(double seconds) const
252 {
253 return Glib::wrap(g_date_time_add_seconds(const_cast<GDateTime*>(gobj()), seconds));
254 }
255
add_full(int years,int months,int days,int hours,int minutes,double seconds) const256 DateTime DateTime::add_full(int years, int months, int days, int hours, int minutes, double seconds) const
257 {
258 return Glib::wrap(g_date_time_add_full(const_cast<GDateTime*>(gobj()), years, months, days, hours, minutes, seconds));
259 }
260
difference(const DateTime & other) const261 TimeSpan DateTime::difference(const DateTime& other) const
262 {
263 return g_date_time_difference(const_cast<GDateTime*>(gobj()), const_cast<GDateTime*>(other.gobj()));
264 }
265
compare(const DateTime & other) const266 int DateTime::compare(const DateTime& other) const
267 {
268 return g_date_time_compare(const_cast<GDateTime*>(gobj()), static_cast<gconstpointer>(other.gobj()));
269 }
270
hash() const271 guint DateTime::hash() const
272 {
273 return g_date_time_hash(const_cast<GDateTime*>(gobj()));
274 }
275
equal(const DateTime & other) const276 bool DateTime::equal(const DateTime& other) const
277 {
278 return g_date_time_equal(const_cast<GDateTime*>(gobj()), static_cast<gconstpointer>(other.gobj()));
279 }
280
get_ymd(int & year,int & month,int & day) const281 void DateTime::get_ymd(int& year, int& month, int& day) const
282 {
283 g_date_time_get_ymd(const_cast<GDateTime*>(gobj()), &(year), &(month), &(day));
284 }
285
get_year() const286 int DateTime::get_year() const
287 {
288 return g_date_time_get_year(const_cast<GDateTime*>(gobj()));
289 }
290
get_month() const291 int DateTime::get_month() const
292 {
293 return g_date_time_get_month(const_cast<GDateTime*>(gobj()));
294 }
295
get_day_of_month() const296 int DateTime::get_day_of_month() const
297 {
298 return g_date_time_get_day_of_month(const_cast<GDateTime*>(gobj()));
299 }
300
get_week_numbering_year() const301 int DateTime::get_week_numbering_year() const
302 {
303 return g_date_time_get_week_numbering_year(const_cast<GDateTime*>(gobj()));
304 }
305
get_week_of_year() const306 int DateTime::get_week_of_year() const
307 {
308 return g_date_time_get_week_of_year(const_cast<GDateTime*>(gobj()));
309 }
310
get_day_of_week() const311 int DateTime::get_day_of_week() const
312 {
313 return g_date_time_get_day_of_week(const_cast<GDateTime*>(gobj()));
314 }
315
get_day_of_year() const316 int DateTime::get_day_of_year() const
317 {
318 return g_date_time_get_day_of_year(const_cast<GDateTime*>(gobj()));
319 }
320
get_hour() const321 int DateTime::get_hour() const
322 {
323 return g_date_time_get_hour(const_cast<GDateTime*>(gobj()));
324 }
325
get_minute() const326 int DateTime::get_minute() const
327 {
328 return g_date_time_get_minute(const_cast<GDateTime*>(gobj()));
329 }
330
get_second() const331 int DateTime::get_second() const
332 {
333 return g_date_time_get_second(const_cast<GDateTime*>(gobj()));
334 }
335
get_microsecond() const336 int DateTime::get_microsecond() const
337 {
338 return g_date_time_get_microsecond(const_cast<GDateTime*>(gobj()));
339 }
340
get_seconds() const341 double DateTime::get_seconds() const
342 {
343 return g_date_time_get_seconds(const_cast<GDateTime*>(gobj()));
344 }
345
to_unix() const346 gint64 DateTime::to_unix() const
347 {
348 return g_date_time_to_unix(const_cast<GDateTime*>(gobj()));
349 }
350
351 #ifndef GLIBMM_DISABLE_DEPRECATED
352 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
to_timeval(TimeVal & tv) const353 bool DateTime::to_timeval(TimeVal& tv) const
354 {
355 return g_date_time_to_timeval(const_cast<GDateTime*>(gobj()), &(tv));
356 }
357 G_GNUC_END_IGNORE_DEPRECATIONS
358 #endif // GLIBMM_DISABLE_DEPRECATED
359
get_utc_offset() const360 TimeSpan DateTime::get_utc_offset() const
361 {
362 return g_date_time_get_utc_offset(const_cast<GDateTime*>(gobj()));
363 }
364
get_timezone() const365 TimeZone DateTime::get_timezone() const
366 {
367 return Glib::wrap(g_date_time_get_timezone(const_cast<GDateTime*>(gobj())), true);
368 }
369
get_timezone_abbreviation() const370 Glib::ustring DateTime::get_timezone_abbreviation() const
371 {
372 return Glib::convert_const_gchar_ptr_to_ustring(g_date_time_get_timezone_abbreviation(const_cast<GDateTime*>(gobj())));
373 }
374
is_daylight_savings() const375 bool DateTime::is_daylight_savings() const
376 {
377 return g_date_time_is_daylight_savings(const_cast<GDateTime*>(gobj()));
378 }
379
to_timezone(const TimeZone & tz) const380 DateTime DateTime::to_timezone(const TimeZone& tz) const
381 {
382 return Glib::wrap(g_date_time_to_timezone(const_cast<GDateTime*>(gobj()), const_cast<GTimeZone*>(tz.gobj())));
383 }
384
to_local() const385 DateTime DateTime::to_local() const
386 {
387 return Glib::wrap(g_date_time_to_local(const_cast<GDateTime*>(gobj())));
388 }
389
to_utc() const390 DateTime DateTime::to_utc() const
391 {
392 return Glib::wrap(g_date_time_to_utc(const_cast<GDateTime*>(gobj())));
393 }
394
format(const Glib::ustring & format_str) const395 Glib::ustring DateTime::format(const Glib::ustring& format_str) const
396 {
397 return Glib::convert_return_gchar_ptr_to_ustring(g_date_time_format(const_cast<GDateTime*>(gobj()), format_str.c_str()));
398 }
399
format_iso8601() const400 Glib::ustring DateTime::format_iso8601() const
401 {
402 return Glib::convert_return_gchar_ptr_to_ustring(g_date_time_format_iso8601(const_cast<GDateTime*>(gobj())));
403 }
404
405
406 } // namespace Glib
407
408
409