author | zautrix <zautrix> | 2004-06-29 11:59:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-29 11:59:46 (UTC) |
commit | da43dbdc6c82453228f34766fc74585615cba938 (patch) (unidiff) | |
tree | 16576932cea08bf117b2d0320b0d5f66ee8ad093 /libical/src/libical/icalrecur.h | |
parent | 627489ea2669d3997676bc3cee0f5d0d0c16c4d4 (diff) | |
download | kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.zip kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.gz kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.bz2 |
New lib ical.Some minor changes as well.
Diffstat (limited to 'libical/src/libical/icalrecur.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libical/src/libical/icalrecur.h | 71 |
1 files changed, 48 insertions, 23 deletions
diff --git a/libical/src/libical/icalrecur.h b/libical/src/libical/icalrecur.h index 5fcdc15..5f6ac55 100644 --- a/libical/src/libical/icalrecur.h +++ b/libical/src/libical/icalrecur.h | |||
@@ -16,10 +16,17 @@ | |||
16 | 16 | ||
17 | The Mozilla Public License Version 1.0. You may obtain a copy of | 17 | The Mozilla Public License Version 1.0. You may obtain a copy of |
18 | the License at http://www.mozilla.org/MPL/ | 18 | the License at http://www.mozilla.org/MPL/ |
19 | */ | ||
20 | |||
21 | /** | ||
22 | @file icalrecur.h | ||
23 | @brief Routines for dealing with recurring time | ||
19 | 24 | ||
20 | How to use: | 25 | How to use: |
21 | 26 | ||
22 | 1) Get a rule and a start time from a component | 27 | 1) Get a rule and a start time from a component |
28 | |||
29 | @code | ||
23 | icalproperty rrule; | 30 | icalproperty rrule; |
24 | struct icalrecurrencetype recur; | 31 | struct icalrecurrencetype recur; |
25 | struct icaltimetype dtstart; | 32 | struct icaltimetype dtstart; |
@@ -27,26 +34,36 @@ How to use: | |||
27 | rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY); | 34 | rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY); |
28 | recur = icalproperty_get_rrule(rrule); | 35 | recur = icalproperty_get_rrule(rrule); |
29 | start = icalproperty_get_dtstart(dtstart); | 36 | start = icalproperty_get_dtstart(dtstart); |
37 | @endcode | ||
30 | 38 | ||
31 | Or, just make them up: | 39 | Or, just make them up: |
40 | |||
41 | @code | ||
32 | recur = icalrecurrencetype_from_string("FREQ=YEARLY;BYDAY=SU,WE"); | 42 | recur = icalrecurrencetype_from_string("FREQ=YEARLY;BYDAY=SU,WE"); |
33 | dtstart = icaltime_from_string("19970101T123000") | 43 | dtstart = icaltime_from_string("19970101T123000") |
44 | @endcode | ||
34 | 45 | ||
35 | 2) Create an iterator | 46 | 2) Create an iterator |
47 | |||
48 | @code | ||
36 | icalrecur_iterator* ritr; | 49 | icalrecur_iterator* ritr; |
37 | ritr = icalrecur_iterator_new(recur,start); | 50 | ritr = icalrecur_iterator_new(recur,start); |
51 | @endcode | ||
38 | 52 | ||
39 | 3) Iterator over the occurrences | 53 | 3) Iterator over the occurrences |
54 | |||
55 | @code | ||
40 | struct icaltimetype next; | 56 | struct icaltimetype next; |
41 | while (next = icalrecur_iterator_next(ritr) | 57 | while (next = icalrecur_iterator_next(ritr) |
42 | && !icaltime_is_null_time(next){ | 58 | && !icaltime_is_null_time(next){ |
43 | Do something with next | 59 | Do something with next |
44 | } | 60 | } |
61 | @endcode | ||
45 | 62 | ||
46 | Note that that the time returned by icalrecur_iterator_next is in | 63 | Note that that the time returned by icalrecur_iterator_next is in |
47 | whatever timezone that dtstart is in. | 64 | whatever timezone that dtstart is in. |
48 | 65 | ||
49 | ======================================================================*/ | 66 | */ |
50 | 67 | ||
51 | #ifndef ICALRECUR_H | 68 | #ifndef ICALRECUR_H |
52 | #define ICALRECUR_H | 69 | #define ICALRECUR_H |
@@ -54,9 +71,9 @@ whatever timezone that dtstart is in. | |||
54 | #include <time.h> | 71 | #include <time.h> |
55 | #include "icaltime.h" | 72 | #include "icaltime.h" |
56 | 73 | ||
57 | /*********************************************************************** | 74 | /* |
58 | * Recurrance enumerations | 75 | * Recurrance enumerations |
59 | **********************************************************************/ | 76 | */ |
60 | 77 | ||
61 | typedef enum icalrecurrencetype_frequency | 78 | typedef enum icalrecurrencetype_frequency |
62 | { | 79 | { |
@@ -93,7 +110,9 @@ enum { | |||
93 | 110 | ||
94 | 111 | ||
95 | 112 | ||
96 | /********************** Recurrence type routines **************/ | 113 | /** |
114 | * Recurrence type routines | ||
115 | */ | ||
97 | 116 | ||
98 | /* See RFC 2445 Section 4.3.10, RECUR Value, for an explaination of | 117 | /* See RFC 2445 Section 4.3.10, RECUR Value, for an explaination of |
99 | the values and fields in struct icalrecurrencetype */ | 118 | the values and fields in struct icalrecurrencetype */ |
@@ -108,7 +127,7 @@ enum { | |||
108 | #define ICAL_BY_MONTH_SIZE 13 | 127 | #define ICAL_BY_MONTH_SIZE 13 |
109 | #define ICAL_BY_SETPOS_SIZE 367 | 128 | #define ICAL_BY_SETPOS_SIZE 367 |
110 | 129 | ||
111 | /* Main struct for holding digested recurrence rules */ | 130 | /** Main struct for holding digested recurrence rules */ |
112 | struct icalrecurrencetype | 131 | struct icalrecurrencetype |
113 | { | 132 | { |
114 | icalrecurrencetype_frequency freq; | 133 | icalrecurrencetype_frequency freq; |
@@ -145,43 +164,49 @@ struct icalrecurrencetype | |||
145 | 164 | ||
146 | void icalrecurrencetype_clear(struct icalrecurrencetype *r); | 165 | void icalrecurrencetype_clear(struct icalrecurrencetype *r); |
147 | 166 | ||
148 | /* The 'day' element of the by_day array is encoded to allow | 167 | /** |
149 | representation of both the day of the week ( Monday, Tueday), but also | 168 | * Array Encoding |
150 | the Nth day of the week ( First tuesday of the month, last thursday of | 169 | * |
151 | the year) These routines decode the day values */ | 170 | * The 'day' element of the by_day array is encoded to allow |
171 | * representation of both the day of the week ( Monday, Tueday), but also | ||
172 | * the Nth day of the week ( First tuesday of the month, last thursday of | ||
173 | * the year) These routines decode the day values | ||
174 | */ | ||
152 | 175 | ||
153 | /* 1 == Monday, etc. */ | 176 | /** 1 == Monday, etc. */ |
154 | enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day); | 177 | enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day); |
155 | 178 | ||
156 | /* 0 == any of day of week. 1 == first, 2 = second, -2 == second to last, etc */ | 179 | /** 0 == any of day of week. 1 == first, 2 = second, -2 == second to last, etc */ |
157 | short icalrecurrencetype_day_position(short day); | 180 | int icalrecurrencetype_day_position(short day); |
158 | 181 | ||
159 | 182 | ||
160 | /*********************************************************************** | 183 | /** Recurrance rule parser */ |
161 | * Recurrance rule parser | ||
162 | **********************************************************************/ | ||
163 | 184 | ||
164 | /* Convert between strings ans recurrencetype structures. */ | 185 | /** Convert between strings and recurrencetype structures. */ |
165 | struct icalrecurrencetype icalrecurrencetype_from_string(const char* str); | 186 | struct icalrecurrencetype icalrecurrencetype_from_string(const char* str); |
166 | char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur); | 187 | char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur); |
167 | 188 | ||
168 | 189 | ||
169 | /********** recurrence iteration routines ********************/ | 190 | /** Recurrence iteration routines */ |
170 | 191 | ||
171 | typedef void icalrecur_iterator; | 192 | typedef struct icalrecur_iterator_impl icalrecur_iterator; |
172 | 193 | ||
173 | /* Create a new recurrence rule iterator */ | 194 | /** Create a new recurrence rule iterator */ |
174 | icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule, | 195 | icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule, |
175 | struct icaltimetype dtstart); | 196 | struct icaltimetype dtstart); |
176 | 197 | ||
177 | /* Get the next occurrence from an iterator */ | 198 | /** Get the next occurrence from an iterator */ |
178 | struct icaltimetype icalrecur_iterator_next(icalrecur_iterator*); | 199 | struct icaltimetype icalrecur_iterator_next(icalrecur_iterator*); |
179 | 200 | ||
180 | /* Free the iterator */ | 201 | void icalrecur_iterator_decrement_count(icalrecur_iterator*); |
202 | |||
203 | /** Free the iterator */ | ||
181 | void icalrecur_iterator_free(icalrecur_iterator*); | 204 | void icalrecur_iterator_free(icalrecur_iterator*); |
182 | 205 | ||
183 | /* Fills array up with at most 'count' time_t values, each | 206 | /** |
184 | representing an occurrence time in seconds past the POSIX epoch */ | 207 | * Fills array up with at most 'count' time_t values, each |
208 | * representing an occurrence time in seconds past the POSIX epoch | ||
209 | */ | ||
185 | int icalrecur_expand_recurrence(char* rule, time_t start, | 210 | int icalrecur_expand_recurrence(char* rule, time_t start, |
186 | int count, time_t* array); | 211 | int count, time_t* array); |
187 | 212 | ||