Libical API Documentation 3.0

icaltime.h
Go to the documentation of this file.
1/*======================================================================
2 FILE: icaltime.h
3 CREATOR: eric 02 June 2000
4
5 (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com>
6
7 This library is free software; you can redistribute it and/or modify
8 it under the terms of either:
9
10 The LGPL as published by the Free Software Foundation, version
11 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html
12
13 Or:
14
15 The Mozilla Public License Version 2.0. You may obtain a copy of
16 the License at https://www.mozilla.org/MPL/
17
18 The Original Code is eric. The Initial Developer of the Original
19 Code is Eric Busboom
20======================================================================*/
21
80#ifndef ICALTIME_H
81#define ICALTIME_H
82
83#include "libical_ical_export.h"
84
85#include <time.h>
86
87/* An opaque struct representing a timezone. We declare this here to avoid
88 a circular dependancy. */
89#if !defined(ICALTIMEZONE_DEFINED)
90#define ICALTIMEZONE_DEFINED
91 typedef struct _icaltimezone icaltimezone;
92#endif
93
95 struct icaltime_span
96{
97 time_t start;
98 time_t end;
99 int is_busy;
100};
101
102 typedef struct icaltime_span icaltime_span;
103
104 struct icaltimetype
105{
106 int year;
107 int month;
108 int day;
109 int hour;
110 int minute;
111 int second;
112
113 int is_date;
115 int is_daylight;
117 const icaltimezone *zone;
118};
119
120 typedef struct icaltimetype icaltimetype;
121
127LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_null_time(void);
128
133LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_null_date(void);
134
139LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_current_time_with_zone(const icaltimezone *zone);
140
145LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_today(void);
146
170LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_timet_with_zone(const time_t tm,
171 const int is_date,
172 const icaltimezone *zone);
173
183LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_string(const char *str);
184
191LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_day_of_year(const int doy, const int year);
192
200LIBICAL_ICAL_EXPORT time_t icaltime_as_timet(const struct icaltimetype);
201
210LIBICAL_ICAL_EXPORT time_t icaltime_as_timet_with_zone(const struct icaltimetype tt,
211 const icaltimezone *zone);
212
219LIBICAL_ICAL_EXPORT const char *icaltime_as_ical_string(const struct icaltimetype tt);
220
227LIBICAL_ICAL_EXPORT char *icaltime_as_ical_string_r(const struct icaltimetype tt);
228
230LIBICAL_ICAL_EXPORT const icaltimezone *icaltime_get_timezone(const struct icaltimetype t);
231
233LIBICAL_ICAL_EXPORT const char *icaltime_get_tzid(const struct icaltimetype t);
234
241LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_set_timezone(struct icaltimetype *t,
242 const icaltimezone *zone);
243
247LIBICAL_ICAL_EXPORT int icaltime_day_of_year(const struct icaltimetype t);
248
253LIBICAL_ICAL_EXPORT int icaltime_day_of_week(const struct icaltimetype t);
254
263LIBICAL_ICAL_EXPORT int icaltime_start_doy_week(const struct icaltimetype t, int fdow);
264
270LIBICAL_ICAL_EXPORT int icaltime_week_number(const struct icaltimetype t);
271
273LIBICAL_ICAL_EXPORT int icaltime_is_null_time(const struct icaltimetype t);
274
281LIBICAL_ICAL_EXPORT int icaltime_is_valid_time(const struct icaltimetype t);
282
288LIBICAL_ICAL_EXPORT int icaltime_is_date(const struct icaltimetype t);
289
294LIBICAL_ICAL_EXPORT int icaltime_is_utc(const struct icaltimetype t);
295
302LIBICAL_ICAL_EXPORT int icaltime_compare(const struct icaltimetype a, const struct icaltimetype b);
303
309LIBICAL_ICAL_EXPORT int icaltime_compare_date_only(const struct icaltimetype a,
310 const struct icaltimetype b);
311
318LIBICAL_ICAL_EXPORT int icaltime_compare_date_only_tz(const struct icaltimetype a,
319 const struct icaltimetype b,
320 icaltimezone *tz);
321
332LIBICAL_ICAL_EXPORT void icaltime_adjust(struct icaltimetype *tt,
333 const int days, const int hours,
334 const int minutes, const int seconds);
335
345LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_normalize(const struct icaltimetype t);
346
357LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_convert_to_zone(const struct icaltimetype tt,
358 icaltimezone *zone);
359
361LIBICAL_ICAL_EXPORT int icaltime_days_in_month(const int month, const int year);
362
368LIBICAL_ICAL_EXPORT int icaltime_is_leap_year(const int year);
369
371LIBICAL_ICAL_EXPORT int icaltime_days_in_year(const int year);
372
382LIBICAL_ICAL_EXPORT struct icaltime_span icaltime_span_new(struct icaltimetype dtstart,
383 struct icaltimetype dtend, int is_busy);
384
398LIBICAL_ICAL_EXPORT int icaltime_span_overlaps(icaltime_span *s1, icaltime_span *s2);
399
408LIBICAL_ICAL_EXPORT int icaltime_span_contains(icaltime_span *s, icaltime_span *container);
409
410#endif /* !ICALTIME_H */
icaltime_is_utc
int icaltime_is_utc(const struct icaltimetype t)
Returns true if the time is relative to UTC zone.
Definition: icaltime.c:604
icaltime_compare
int icaltime_compare(const struct icaltimetype a, const struct icaltimetype b)
Returns -1, 0, or 1 to indicate that a is less than b, a equals b, or a is greater than b.
Definition: icaltime.c:618
icaltime_compare_date_only
int icaltime_compare_date_only(const struct icaltimetype a, const struct icaltimetype b)
Like icaltime_compare, but only use the date parts.
Definition: icaltime.c:673
icaltime_span_contains
int icaltime_span_contains(icaltime_span *s, icaltime_span *container)
Returns true if the span is totally within the containing span.
Definition: icaltime.c:940
icaltime_from_string
struct icaltimetype icaltime_from_string(const char *str)
Contructor.
Definition: icaltime.c:339
icaltime_get_tzid
const char * icaltime_get_tzid(const struct icaltimetype t)
Returns the tzid, or NULL for a floating time.
Definition: icaltime.c:859
icaltime_from_day_of_year
struct icaltimetype icaltime_from_day_of_year(const int doy, const int year)
Contructor.
Definition: icaltime.c:527
icaltime_current_time_with_zone
struct icaltimetype icaltime_current_time_with_zone(const icaltimezone *zone)
Convenience constructor.
Definition: icaltime.c:221
icaltime_day_of_year
int icaltime_day_of_year(const struct icaltimetype t)
Returns the day of the year, counting from 1 (Jan 1st).
Definition: icaltime.c:520
icaltime_start_doy_week
int icaltime_start_doy_week(const struct icaltimetype t, int fdow)
Returns the day of the year for the first day of the week that the given time is within.
Definition: icaltime.c:477
icaltime_span_new
struct icaltime_span icaltime_span_new(struct icaltimetype dtstart, struct icaltimetype dtend, int is_busy)
Builds an icaltimespan given a start time, end time and busy value.
Definition: icaltime.c:884
icaltime_as_timet_with_zone
time_t icaltime_as_timet_with_zone(const struct icaltimetype tt, const icaltimezone *zone)
Returns the time as seconds past the UNIX epoch, using the given timezone.
Definition: icaltime.c:262
icaltime_get_timezone
const icaltimezone * icaltime_get_timezone(const struct icaltimetype t)
Returns the timezone.
Definition: icaltime.c:854
icaltime_week_number
int icaltime_week_number(const struct icaltimetype t)
Returns the week number for the week the given time is within.
Definition: icaltime.c:501
icaltime_day_of_week
int icaltime_day_of_week(const struct icaltimetype t)
Returns the day of the week of the given time.
Definition: icaltime.c:459
icaltime_is_date
int icaltime_is_date(const struct icaltimetype t)
Returns true if time is a DATE.
Definition: icaltime.c:599
icaltime_today
struct icaltimetype icaltime_today(void)
Convenience constructor.
Definition: icaltime.c:226
icaltime_as_timet
time_t icaltime_as_timet(const struct icaltimetype)
Definition: icaltime.c:231
icaltime_null_date
struct icaltimetype icaltime_null_date(void)
Constructor.
Definition: icaltime.c:571
icaltime_from_timet_with_zone
struct icaltimetype icaltime_from_timet_with_zone(const time_t tm, const int is_date, const icaltimezone *zone)
Constructor.
Definition: icaltime.c:183
icaltime_span_overlaps
int icaltime_span_overlaps(icaltime_span *s1, icaltime_span *s2)
Returns true if the two spans overlap.
Definition: icaltime.c:916
icaltime_as_ical_string
const char * icaltime_as_ical_string(const struct icaltimetype tt)
Returns a string represention of the time, in RFC5545 format.
Definition: icaltime.c:300
icaltime_is_null_time
int icaltime_is_null_time(const struct icaltimetype t)
Returns true if the time is null.
Definition: icaltime.c:609
icaltime_days_in_month
int icaltime_days_in_month(const int month, const int year)
Definition: icaltime.c:435
icaltime_convert_to_zone
struct icaltimetype icaltime_convert_to_zone(const struct icaltimetype tt, icaltimezone *zone)
Converts time to a given timezone.
Definition: icaltime.c:825
icaltime_is_valid_time
int icaltime_is_valid_time(const struct icaltimetype t)
Returns false if the time is clearly invalid, but is not null.
Definition: icaltime.c:590
icaltime_normalize
struct icaltimetype icaltime_normalize(const struct icaltimetype t)
Normalizes the icaltime, so all of the time components are in their normal ranges.
Definition: icaltime.c:331
icaltime_compare_date_only_tz
int icaltime_compare_date_only_tz(const struct icaltimetype a, const struct icaltimetype b, icaltimezone *tz)
Like icaltime_compare, but only use the date parts; accepts timezone.
Definition: icaltime.c:703
icaltime_days_in_year
int icaltime_days_in_year(const int year)
Definition: icaltime.c:424
icaltime_is_leap_year
int icaltime_is_leap_year(const int year)
Returns whether the specified year is a leap year.
Definition: icaltime.c:415
icaltime_set_timezone
struct icaltimetype icaltime_set_timezone(struct icaltimetype *t, const icaltimezone *zone)
Sets the timezone.
Definition: icaltime.c:868
icaltime_adjust
void icaltime_adjust(struct icaltimetype *tt, const int days, const int hours, const int minutes, const int seconds)
Internal, shouldn't be part of the public API.
Definition: icaltime.c:740
icaltime_null_time
struct icaltimetype icaltime_null_time(void)
Constructor.
Definition: icaltime.c:562
icaltime_as_ical_string_r
char * icaltime_as_ical_string_r(const struct icaltimetype tt)
Returns a string represention of the time, in RFC5545 format.
Definition: icaltime.c:309
_icaltimezone
Definition: icaltimezoneimpl.h:23
icaltime_span
Definition: icaltime.h:96
icaltime_span::start
time_t start
Definition: icaltime.h:97
icaltime_span::end
time_t end
Definition: icaltime.h:98
icaltime_span::is_busy
int is_busy
Definition: icaltime.h:99
icaltimetype
Definition: icaltime.h:105
icaltimetype::is_date
int is_date
Definition: icaltime.h:113
icaltimetype::year
int year
Definition: icaltime.h:106
icaltimetype::is_daylight
int is_daylight
Definition: icaltime.h:115
icaltimetype::zone
const icaltimezone * zone
Definition: icaltime.h:117
icaltimetype::month
int month
Definition: icaltime.h:107