summaryrefslogtreecommitdiff
path: root/glib/src/timezone.hg
blob: 8d28c4e412ad7a71f3805684146aeb608956e59e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* Copyright (C) 2011 The glibmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

_DEFS(glibmm,glib)

#include <glibmmconfig.h>
#include <glibmm/ustring.h>
#include <glibmm/value.h>
#include <glib.h>

#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GTimeZone GTimeZone;
#endif

namespace Glib
{

_WRAP_ENUM(TimeType, GTimeType, NO_GTYPE, decl_prefix GLIBMM_API)

/** TimeZone - A structure representing a time zone.
 * TimeZone is a structure that represents a time zone, at no particular point
 * in time. It is immutable.
 *
 * A time zone contains a number of intervals. Each interval has an
 * abbreviation to describe it, an offet to UTC and a flag indicating if the
 * daylight savings time is in effect during that interval. A time zone always
 * has at least one interval -- interval 0.
 *
 * Every UTC time is contained within exactly one interval, but a given local
 * time may be contained within zero, one or two intervals (due to
 * incontinuities associated with daylight savings time).
 *
 * An interval may refer to a specific period of time (eg: the duration of
 * daylight savings time during 2010) or it may refer to many periods of time
 * that share the same properties (eg: all periods of daylight savings time).
 * It is also possible (usually for political reasons) that some properties
 * (like the abbreviation) change between intervals without other properties
 * changing.
 * @newin{2,30}
 */
class GLIBMM_API TimeZone
{
  // GTimeZone is refcounted, but Glib::TimeZone is not.
  // GTimeZone is immutable. Therefore, there is no problem having several
  // Glib::TimeZone instances wrap the same GTimeZone, and it's easier to use
  // Glib::TimeZone without Glib::RefPtr.
  _CLASS_BOXEDTYPE(TimeZone, GTimeZone, NONE, g_time_zone_ref, g_time_zone_unref, GLIBMM_API)
  _IGNORE(g_time_zone_ref, g_time_zone_unref)

public:
  // We hand-code create(const Glib::ustring& identifier).
  // g_time_zone_new() is deprecated in glib 2.68.
  // We can't use the replacement g_time_zone_new_identifier(),
  // which is new in glib 2.68. This version of glibmm does not require glib 2.68.
  //_WRAP_METHOD(static TimeZone create(const Glib::ustring& identifier), g_time_zone_new_identifier)
  _WRAP_METHOD_DOCS_ONLY(g_time_zone_new)
  static TimeZone create(const Glib::ustring& identifier);

  _WRAP_METHOD(static TimeZone create_local(), g_time_zone_new_local)
  _WRAP_METHOD(static TimeZone create_utc(), g_time_zone_new_utc)

  _WRAP_METHOD(int find_interval(TimeType type, gint64 time) const, g_time_zone_find_interval)
  _WRAP_METHOD(int adjust_time(TimeType type, gint64& time) const, g_time_zone_adjust_time)
  _WRAP_METHOD(Glib::ustring get_abbreviation(int interval) const, g_time_zone_get_abbreviation)
  _WRAP_METHOD(gint32 get_offset(int interval) const, g_time_zone_get_offset)
  _WRAP_METHOD(bool is_dst(int interval) const, g_time_zone_is_dst)
  _WRAP_METHOD(Glib::ustring get_identifier() const, g_time_zone_get_identifier, newin "2,60")
};

} // namespace Glib