summaryrefslogtreecommitdiffabout
path: root/libical/src/libical/icaltimezone.h
Unidiff
Diffstat (limited to 'libical/src/libical/icaltimezone.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libical/icaltimezone.h167
1 files changed, 167 insertions, 0 deletions
diff --git a/libical/src/libical/icaltimezone.h b/libical/src/libical/icaltimezone.h
new file mode 100644
index 0000000..08af2c1
--- a/dev/null
+++ b/libical/src/libical/icaltimezone.h
@@ -0,0 +1,167 @@
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/*======================================================================
3 FILE: icaltimezone.h
4 CREATOR: Damon Chaplin 15 March 2001
5
6
7 $Id$
8 $Locker$
9
10 (C) COPYRIGHT 2001, Damon Chaplin
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of either:
14
15 The LGPL as published by the Free Software Foundation, version
16 2.1, available at: http://www.fsf.org/copyleft/lesser.html
17
18 Or:
19
20 The Mozilla Public License Version 1.0. You may obtain a copy of
21 the License at http://www.mozilla.org/MPL/
22
23
24======================================================================*/
25/**
26 * @file icaltimezone.h
27 * @brief timezone handling routines
28 */
29
30#ifndef ICALTIMEZONE_H
31#define ICALTIMEZONE_H
32
33#include <stdio.h> /* For FILE* */
34#include "icaltime.h"
35#include "icalarray.h"
36#include "icalcomponent.h"
37
38
39#ifndef ICALTIMEZONE_DEFINED
40#define ICALTIMEZONE_DEFINED
41/** @brief An opaque struct representing a timezone.
42 * We declare this here to avoid a circular dependancy.
43 */
44 typedef struct _icaltimezone icaltimezone;
45#endif
46
47/**
48 * @par Creating/Destroying individual icaltimezones.
49 */
50
51/** Creates a new icaltimezone. */
52 icaltimezone *icaltimezone_new (void);
53
54/** Frees all memory used for the icaltimezone. Set free_struct to free the
55 icaltimezone struct as well. */
56 void icaltimezone_free (icaltimezone *zone,
57 int free_struct);
58
59
60/**
61 * @par Accessing timezones.
62 */
63
64/** Free any builtin timezone information **/
65void icaltimezone_free_builtin_timezones(void);
66
67/** Returns the array of builtin icaltimezones. */
68 icalarray* icaltimezone_get_builtin_timezones(void);
69
70/** Returns a single builtin timezone, given its Olson city name. */
71 icaltimezone* icaltimezone_get_builtin_timezone(const char *location);
72
73/** Returns a single builtin timezone, given its TZID. */
74icaltimezone* icaltimezone_get_builtin_timezone_from_tzid (const char *tzid);
75
76/** Returns the UTC timezone. */
77 icaltimezone* icaltimezone_get_utc_timezone(void);
78
79/** Returns the TZID of a timezone. */
80 char* icaltimezone_get_tzid (icaltimezone*zone);
81
82/** Returns the city name of a timezone. */
83 char* icaltimezone_get_location (icaltimezone*zone);
84
85/** Returns the TZNAME properties used in the latest STANDARD and DAYLIGHT
86 components. If they are the same it will return just one, e.g. "LMT".
87 If they are different it will format them like "EST/EDT". Note that this
88 may also return NULL. */
89 char* icaltimezone_get_tznames (icaltimezone*zone);
90
91/** Returns the latitude of a builtin timezone. */
92 double icaltimezone_get_latitude (icaltimezone*zone);
93
94/** Returns the longitude of a builtin timezone. */
95 double icaltimezone_get_longitude (icaltimezone*zone);
96
97/** Returns the VTIMEZONE component of a timezone. */
98 icalcomponent* icaltimezone_get_component (icaltimezone*zone);
99
100/** Sets the VTIMEZONE component of an icaltimezone, initializing the tzid,
101 location & tzname fields. It returns 1 on success or 0 on failure, i.e.
102 no TZID was found. */
103 int icaltimezone_set_component (icaltimezone*zone,
104 icalcomponent*comp);
105
106/**
107 * @par Converting times between timezones.
108 */
109
110 void icaltimezone_convert_time (struct icaltimetype *tt,
111 icaltimezone*from_zone,
112 icaltimezone*to_zone);
113
114
115/**
116 * @par Getting offsets from UTC.
117 */
118
119/** Calculates the UTC offset of a given local time in the given
120 timezone. It is the number of seconds to add to UTC to get local
121 time. The is_daylight flag is set to 1 if the time is in
122 daylight-savings time. */
123 int icaltimezone_get_utc_offset (icaltimezone*zone,
124 struct icaltimetype *tt,
125 int *is_daylight);
126
127/** Calculates the UTC offset of a given UTC time in the given
128 timezone. It is the number of seconds to add to UTC to get local
129 time. The is_daylight flag is set to 1 if the time is in
130 daylight-savings time. */
131 int icaltimezone_get_utc_offset_of_utc_time (icaltimezone*zone,
132 struct icaltimetype *tt,
133 int *is_daylight);
134
135
136
137/*
138 * Handling arrays of timezones. Mainly for internal use.
139 */
140 icalarray* icaltimezone_array_new (void);
141
142 void icaltimezone_array_append_from_vtimezone (icalarray *timezones,
143 icalcomponent *child);
144 void icaltimezone_array_free (icalarray*timezones);
145
146
147/*
148 * @par Handling the default location the timezone files
149 */
150
151/** Set the directory to look for the zonefiles */
152void set_zone_directory(char *path);
153
154/** Free memory dedicated to the zonefile directory */
155void free_zone_directory(void);
156
157/*
158 * @par Debugging Output.
159 */
160
161/** Dumps information about changes in the timezone up to and including
162 max_year. */
163 int icaltimezone_dump_changes (icaltimezone*zone,
164 int max_year,
165 FILE *fp);
166
167#endif /* ICALTIMEZONE_H */