Libical API Documentation 4.0 UNRELEASED Go to the stable 3.0 documentation
Loading...
Searching...
No Matches
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 SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
7
8 The Original Code is eric. The Initial Developer of the Original
9 Code is Eric Busboom
10======================================================================*/
11
68
69#ifndef ICALTIME_H
70#define ICALTIME_H
71
72#include "libical_ical_export.h"
73
74#include <stdbool.h>
75#include <time.h>
76// clang-format off
77#define icaltime_t time_t
78// clang-format on
79
80/* An opaque struct representing a timezone. We declare this here to avoid
81 a circular dependency. */
82#if !defined(ICALTIMEZONE_DEFINED)
83#define ICALTIMEZONE_DEFINED
85#endif
86
89 icaltime_t start;
90 icaltime_t end;
91 int is_busy;
92};
93
94typedef struct icaltime_span icaltime_span;
95
97 int year;
98 int month;
99 int day;
100 int hour;
101 int minute;
102 int second;
103
105
107
109};
110
111typedef struct icaltimetype icaltimetype;
112
113#define ICALTIMETYPE_INITIALIZER {0, 0, 0, 0, 0, 0, 0, 0, 0}
114
120LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_null_time(void);
121
126LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_null_date(void);
127
132LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_current_time_with_zone(const icaltimezone *zone);
133
138LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_today(void);
139
163LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_timet_with_zone(const icaltime_t tm,
164 const bool is_date,
165 const icaltimezone *zone);
166
180LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_string(const char *str);
181
187LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_day_of_year(const int doy, const int year);
188
199LIBICAL_ICAL_EXPORT icaltime_t icaltime_as_timet(const struct icaltimetype);
200
209LIBICAL_ICAL_EXPORT icaltime_t icaltime_as_timet_with_zone(const struct icaltimetype tt,
210 const icaltimezone *zone);
211
218LIBICAL_ICAL_EXPORT const char *icaltime_as_ical_string(const struct icaltimetype tt);
219
226LIBICAL_ICAL_EXPORT char *icaltime_as_ical_string_r(const struct icaltimetype tt);
227
229LIBICAL_ICAL_EXPORT const icaltimezone *icaltime_get_timezone(const struct icaltimetype t);
230
232LIBICAL_ICAL_EXPORT const char *icaltime_get_tzid(const struct icaltimetype t);
233
248LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_set_timezone(struct icaltimetype *t,
249 const icaltimezone *zone);
250
254LIBICAL_ICAL_EXPORT int icaltime_day_of_year(const struct icaltimetype t);
255
260LIBICAL_ICAL_EXPORT int icaltime_day_of_week(const struct icaltimetype t);
261
270LIBICAL_ICAL_EXPORT int icaltime_start_doy_week(const struct icaltimetype t, int fdow);
271
273LIBICAL_ICAL_EXPORT bool icaltime_is_null_time(const struct icaltimetype t);
274
281LIBICAL_ICAL_EXPORT bool icaltime_is_valid_time(const struct icaltimetype t);
282
287LIBICAL_ICAL_EXPORT bool icaltime_is_date(const struct icaltimetype t);
288
293LIBICAL_ICAL_EXPORT bool icaltime_is_utc(const struct icaltimetype t);
294
301LIBICAL_ICAL_EXPORT int icaltime_compare(const struct icaltimetype a, const struct icaltimetype b);
302
308LIBICAL_ICAL_EXPORT int icaltime_compare_date_only(const struct icaltimetype a,
309 const struct icaltimetype b);
310
317LIBICAL_ICAL_EXPORT int icaltime_compare_date_only_tz(const struct icaltimetype a,
318 const struct icaltimetype b,
319 icaltimezone *tz);
320
330LIBICAL_ICAL_EXPORT void icaltime_adjust(struct icaltimetype *tt,
331 const int days, const int hours,
332 const int minutes, const int seconds);
333
343LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_normalize(const struct icaltimetype tt);
344
362LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_convert_to_zone(const struct icaltimetype tt,
364
366LIBICAL_ICAL_EXPORT int icaltime_days_in_month(const int month, const int year);
367
373LIBICAL_ICAL_EXPORT bool icaltime_is_leap_year(const int year);
374
376LIBICAL_ICAL_EXPORT int icaltime_days_in_year(const int year);
377
387LIBICAL_ICAL_EXPORT struct icaltime_span icaltime_span_new(struct icaltimetype dtstart,
388 struct icaltimetype dtend, bool is_busy);
389
403LIBICAL_ICAL_EXPORT bool icaltime_span_overlaps(const icaltime_span *s1, const icaltime_span *s2);
404
413LIBICAL_ICAL_EXPORT bool icaltime_span_contains(const icaltime_span *s, const icaltime_span *container);
414
415#endif /* !ICALTIME_H */
416
417/* kate: syntax C; */
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:629
struct icaltime_span icaltime_span_new(struct icaltimetype dtstart, struct icaltimetype dtend, bool is_busy)
Builds an icaltimespan given a start time, end time and busy value.
Definition icaltime.c:902
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:698
bool icaltime_is_date(const struct icaltimetype t)
Returns true if time is a DATE.
Definition icaltime.c:610
struct icaltimetype icaltime_from_string(const char *str)
Definition icaltime.c:368
const char * icaltime_get_tzid(const struct icaltimetype t)
Returns the tzid, or NULL for a floating time.
Definition icaltime.c:877
struct icaltimetype icaltime_from_day_of_year(const int doy, const int year)
Definition icaltime.c:534
struct icaltimetype icaltime_current_time_with_zone(const icaltimezone *zone)
Convenience constructor.
Definition icaltime.c:243
int icaltime_day_of_year(const struct icaltimetype t)
Returns the day of the year, counting from 1 (Jan 1st).
Definition icaltime.c:527
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:506
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:286
bool icaltime_is_leap_year(const int year)
Returns whether the specified year is a leap year.
Definition icaltime.c:445
const icaltimezone * icaltime_get_timezone(const struct icaltimetype t)
Returns the timezone.
Definition icaltime.c:872
int icaltime_day_of_week(const struct icaltimetype t)
Returns the day of the week of the given time.
Definition icaltime.c:491
struct icaltimetype icaltime_today(void)
Convenience constructor.
Definition icaltime.c:248
bool icaltime_span_overlaps(const icaltime_span *s1, const icaltime_span *s2)
Returns true if the two spans overlap.
Definition icaltime.c:917
time_t icaltime_as_timet(const struct icaltimetype)
Definition icaltime.c:253
struct icaltimetype icaltime_null_date(void)
Constructor.
Definition icaltime.c:578
struct _icaltimezone icaltimezone
An opaque struct representing a timezone. We declare this here to avoid a circular dependency.
Definition icaltime.h:84
bool icaltime_is_valid_time(const struct icaltimetype t)
Returns false if the time is clearly invalid, but is not null.
Definition icaltime.c:597
const char * icaltime_as_ical_string(const struct icaltimetype tt)
Returns a string representation of the time, in RFC5545 format.
Definition icaltime.c:326
int icaltime_days_in_month(const int month, const int year)
Definition icaltime.c:465
bool icaltime_is_utc(const struct icaltimetype t)
Returns true if the time is relative to UTC zone.
Definition icaltime.c:615
struct icaltimetype icaltime_convert_to_zone(const struct icaltimetype tt, icaltimezone *zone)
Converts time to a given timezone.
Definition icaltime.c:849
bool icaltime_span_contains(const icaltime_span *s, const icaltime_span *container)
Returns true if the span is totally within the containing span.
Definition icaltime.c:946
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:728
int icaltime_days_in_year(const int year)
Definition icaltime.c:454
bool icaltime_is_null_time(const struct icaltimetype t)
Returns true if the time is null.
Definition icaltime.c:620
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:360
struct icaltimetype icaltime_set_timezone(struct icaltimetype *t, const icaltimezone *zone)
Sets the timezone.
Definition icaltime.c:886
void icaltime_adjust(struct icaltimetype *tt, const int days, const int hours, const int minutes, const int seconds)
Adds or subtracts a number of days, hours, minutes and seconds.
Definition icaltime.c:758
struct icaltimetype icaltime_null_time(void)
Constructor.
Definition icaltime.c:569
struct icaltimetype icaltime_from_timet_with_zone(const time_t tm, const bool is_date, const icaltimezone *zone)
Constructor.
char * icaltime_as_ical_string_r(const struct icaltimetype tt)
Returns a string representation of the time, in RFC5545 format.
Definition icaltime.c:335
Definition icaltimezoneimpl.h:16
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:96
int is_date
Definition icaltime.h:104
int year
Definition icaltime.h:97
int is_daylight
Definition icaltime.h:106
const icaltimezone * zone
Definition icaltime.h:108
int month
Definition icaltime.h:98