Libical API Documentation 3.1
icaltime.h
Go to the documentation of this file.
1/*======================================================================
2 FILE: icaltime.h
3 CREATOR: eric 02 June 2000
4
5 SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com>
6
7 SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
8
9 The Original Code is eric. The Initial Developer of the Original
10 Code is Eric Busboom
11======================================================================*/
12
71#ifndef ICALTIME_H
72#define ICALTIME_H
73
74#include "libical_ical_export.h"
75
76#include <time.h>
77#define icaltime_t time_t
78
79/* An opaque struct representing a timezone. We declare this here to avoid
80 a circular dependency. */
81#if !defined(ICALTIMEZONE_DEFINED)
82#define ICALTIMEZONE_DEFINED
83typedef struct _icaltimezone icaltimezone;
84#endif
85
88{
89 icaltime_t start;
90 icaltime_t end;
91 int is_busy;
92};
93
94typedef struct icaltime_span icaltime_span;
95
97{
98 int year;
99 int month;
100 int day;
101 int hour;
102 int minute;
103 int second;
104
110};
111
112typedef struct icaltimetype icaltimetype;
113
114#define ICALTIMETYPE_INITIALIZER { 0, 0, 0, 0, 0, 0, 0, 0, 0}
115
121LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_null_time(void);
122
127LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_null_date(void);
128
133LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_current_time_with_zone(const icaltimezone *zone);
134
139LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_today(void);
140
164LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_timet_with_zone(const icaltime_t tm,
165 const int is_date,
166 const icaltimezone *zone);
167
177LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_string(const char *str);
178
185LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_day_of_year(const int doy, const int year);
186
194LIBICAL_ICAL_EXPORT icaltime_t icaltime_as_timet(const struct icaltimetype);
195
204LIBICAL_ICAL_EXPORT icaltime_t icaltime_as_timet_with_zone(const struct icaltimetype tt,
205 const icaltimezone *zone);
206
213LIBICAL_ICAL_EXPORT const char *icaltime_as_ical_string(const struct icaltimetype tt);
214
221LIBICAL_ICAL_EXPORT char *icaltime_as_ical_string_r(const struct icaltimetype tt);
222
224LIBICAL_ICAL_EXPORT const icaltimezone *icaltime_get_timezone(const struct icaltimetype t);
225
227LIBICAL_ICAL_EXPORT const char *icaltime_get_tzid(const struct icaltimetype t);
228
243LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_set_timezone(struct icaltimetype *t,
244 const icaltimezone *zone);
245
249LIBICAL_ICAL_EXPORT int icaltime_day_of_year(const struct icaltimetype t);
250
255LIBICAL_ICAL_EXPORT int icaltime_day_of_week(const struct icaltimetype t);
256
265LIBICAL_ICAL_EXPORT int icaltime_start_doy_week(const struct icaltimetype t, int fdow);
266
272LIBICAL_ICAL_EXPORT int icaltime_week_number(const struct icaltimetype t);
273
275LIBICAL_ICAL_EXPORT int icaltime_is_null_time(const struct icaltimetype t);
276
283LIBICAL_ICAL_EXPORT int icaltime_is_valid_time(const struct icaltimetype t);
284
290LIBICAL_ICAL_EXPORT int icaltime_is_date(const struct icaltimetype t);
291
296LIBICAL_ICAL_EXPORT int icaltime_is_utc(const struct icaltimetype t);
297
304LIBICAL_ICAL_EXPORT int icaltime_compare(const struct icaltimetype a, const struct icaltimetype b);
305
311LIBICAL_ICAL_EXPORT int icaltime_compare_date_only(const struct icaltimetype a,
312 const struct icaltimetype b);
313
320LIBICAL_ICAL_EXPORT int icaltime_compare_date_only_tz(const struct icaltimetype a,
321 const struct icaltimetype b,
322 icaltimezone *tz);
323
334LIBICAL_ICAL_EXPORT void icaltime_adjust(struct icaltimetype *tt,
335 const int days, const int hours,
336 const int minutes, const int seconds);
337
347LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_normalize(const struct icaltimetype tt);
348
366LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_convert_to_zone(const struct icaltimetype tt,
368
370LIBICAL_ICAL_EXPORT int icaltime_days_in_month(const int month, const int year);
371
377LIBICAL_ICAL_EXPORT int icaltime_is_leap_year(const int year);
378
380LIBICAL_ICAL_EXPORT int icaltime_days_in_year(const int year);
381
391LIBICAL_ICAL_EXPORT struct icaltime_span icaltime_span_new(struct icaltimetype dtstart,
392 struct icaltimetype dtend, int is_busy);
393
407LIBICAL_ICAL_EXPORT int icaltime_span_overlaps(icaltime_span *s1, icaltime_span *s2);
408
417LIBICAL_ICAL_EXPORT int icaltime_span_contains(icaltime_span *s, icaltime_span *container);
418
419#endif /* !ICALTIME_H */
int icaltime_is_utc(const struct icaltimetype t)
Returns true if the time is relative to UTC zone.
Definition: icaltime.c:588
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:602
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:657
int icaltime_span_contains(icaltime_span *s, icaltime_span *container)
Returns true if the span is totally within the containing span.
Definition: icaltime.c:924
struct icaltimetype icaltime_from_string(const char *str)
Constructor.
Definition: icaltime.c:330
const char * icaltime_get_tzid(const struct icaltimetype t)
Returns the tzid, or NULL for a floating time.
Definition: icaltime.c:843
struct icaltimetype icaltime_from_day_of_year(const int doy, const int year)
Constructor.
Definition: icaltime.c:511
struct icaltimetype icaltime_current_time_with_zone(const icaltimezone *zone)
Convenience constructor.
Definition: icaltime.c:212
int icaltime_day_of_year(const struct icaltimetype t)
Returns the day of the year, counting from 1 (Jan 1st).
Definition: icaltime.c:504
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:467
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:868
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:253
const icaltimezone * icaltime_get_timezone(const struct icaltimetype t)
Returns the timezone.
Definition: icaltime.c:838
int icaltime_week_number(const struct icaltimetype t)
Returns the week number for the week the given time is within.
Definition: icaltime.c:488
int icaltime_day_of_week(const struct icaltimetype t)
Returns the day of the week of the given time.
Definition: icaltime.c:452
int icaltime_is_date(const struct icaltimetype t)
Returns true if time is a DATE.
Definition: icaltime.c:583
struct icaltimetype icaltime_today(void)
Convenience constructor.
Definition: icaltime.c:217
time_t icaltime_as_timet(const struct icaltimetype)
Definition: icaltime.c:222
struct icaltimetype icaltime_null_date(void)
Constructor.
Definition: icaltime.c:555
struct icaltimetype icaltime_from_timet_with_zone(const time_t tm, const int is_date, const icaltimezone *zone)
Constructor.
int icaltime_span_overlaps(icaltime_span *s1, icaltime_span *s2)
Returns true if the two spans overlap.
Definition: icaltime.c:900
const char * icaltime_as_ical_string(const struct icaltimetype tt)
Returns a string represention of the time, in RFC5545 format.
Definition: icaltime.c:291
int icaltime_is_null_time(const struct icaltimetype t)
Returns true if the time is null.
Definition: icaltime.c:593
int icaltime_days_in_month(const int month, const int year)
Definition: icaltime.c:426
struct icaltimetype icaltime_convert_to_zone(const struct icaltimetype tt, icaltimezone *zone)
Converts time to a given timezone.
Definition: icaltime.c:809
int icaltime_is_valid_time(const struct icaltimetype t)
Returns false if the time is clearly invalid, but is not null.
Definition: icaltime.c:574
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:687
int icaltime_days_in_year(const int year)
Definition: icaltime.c:415
int icaltime_is_leap_year(const int year)
Returns whether the specified year is a leap year.
Definition: icaltime.c:406
struct icaltimetype icaltime_normalize(const struct icaltimetype tt)
Normalizes the icaltime, so all of the time components are in their normal ranges.
Definition: icaltime.c:322
struct icaltimetype icaltime_set_timezone(struct icaltimetype *t, const icaltimezone *zone)
Sets the timezone.
Definition: icaltime.c:852
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:724
struct icaltimetype icaltime_null_time(void)
Constructor.
Definition: icaltime.c:546
char * icaltime_as_ical_string_r(const struct icaltimetype tt)
Returns a string represention of the time, in RFC5545 format.
Definition: icaltime.c:300
Definition: icaltimezoneimpl.h:15
Definition: icaltime.h:88
time_t start
Definition: icaltime.h:89
time_t end
Definition: icaltime.h:90
int is_busy
Definition: icaltime.h:91
Definition: icaltime.h:97
int is_date
Definition: icaltime.h:105
int year
Definition: icaltime.h:98
int is_daylight
Definition: icaltime.h:107
const icaltimezone * zone
Definition: icaltime.h:109
int month
Definition: icaltime.h:99