summaryrefslogtreecommitdiffabout
path: root/libical/src/libical/icaltime.h
Unidiff
Diffstat (limited to 'libical/src/libical/icaltime.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libical/icaltime.h145
1 files changed, 145 insertions, 0 deletions
diff --git a/libical/src/libical/icaltime.h b/libical/src/libical/icaltime.h
new file mode 100644
index 0000000..0f0379b
--- a/dev/null
+++ b/libical/src/libical/icaltime.h
@@ -0,0 +1,145 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icaltime.h
4 CREATOR: eric 02 June 2000
5
6
7 $Id$
8 $Locker$
9
10 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
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 The Original Code is eric. The Initial Developer of the Original
24 Code is Eric Busboom
25
26
27======================================================================*/
28
29#ifndef ICALTIME_H
30#define ICALTIME_H
31
32#include <time.h>
33
34/* icaltime_span is returned by icalcomponent_get_span() */
35struct icaltime_span {
36 time_t start; /* in UTC */
37 time_t end; /* in UTC */
38 int is_busy; /* 1->busy time, 0-> free time */
39};
40
41
42struct icaltimetype
43{
44 int year;
45 int month;
46 int day;
47 int hour;
48 int minute;
49 int second;
50
51 int is_utc; /* 1-> time is in UTC timezone */
52
53 int is_date; /* 1 -> interpret this as date. */
54
55 const char* zone; /*Ptr to Olsen placename. Libical does not own mem*/
56 };
57
58/* Convert seconds past UNIX epoch to a timetype*/
59struct icaltimetype icaltime_from_timet(time_t v, int is_date);
60
61/* Return the time as seconds past the UNIX epoch */
62time_t icaltime_as_timet(struct icaltimetype);
63
64/* Return a string represention of the time, in RFC2445 format. The
65 string is owned by libical */
66char* icaltime_as_ical_string(struct icaltimetype tt);
67
68/* Like icaltime_from_timet(), except that the input may be in seconds
69 past the epoch in floating time. This routine is deprecated */
70struct icaltimetype icaltime_from_int(int v, int is_date, int is_utc);
71
72/* Like icaltime_as_timet, but in a floating epoch. This routine is deprecated */
73int icaltime_as_int(struct icaltimetype);
74
75/* create a time from an ISO format string */
76struct icaltimetype icaltime_from_string(const char* str);
77
78/* Routines for handling timezones */
79/* Return the offset of the named zone as seconds. tt is a time
80 indicating the date for which you want the offset */
81int icaltime_utc_offset(struct icaltimetype tt, const char* tzid);
82
83/* convert tt, of timezone tzid, into a utc time. Does nothing if the
84 time is already UTC. */
85struct icaltimetype icaltime_as_utc(struct icaltimetype tt,
86 const char* tzid);
87
88/* convert tt, a time in UTC, into a time in timezone tzid */
89struct icaltimetype icaltime_as_zone(struct icaltimetype tt,
90 const char* tzid);
91
92/* Return a null time, which indicates no time has been set. This time represent the beginning of the epoch */
93struct icaltimetype icaltime_null_time(void);
94
95/* Return true of the time is null. */
96int icaltime_is_null_time(struct icaltimetype t);
97
98/* Returns false if the time is clearly invalid, but is not null. This
99 is usually the result of creating a new time type buy not clearing
100 it, or setting one of the flags to an illegal value. */
101int icaltime_is_valid_time(struct icaltimetype t);
102
103/* Reset all of the time components to be in their normal ranges. For
104 instance, given a time with minutes=70, the minutes will be reduces
105 to 10, and the hour incremented. This allows the caller to do
106 arithmetic on times without worrying about overflow or
107 underflow. */
108struct icaltimetype icaltime_normalize(struct icaltimetype t);
109
110/* Return the day of the year of the given time */
111short icaltime_day_of_year(struct icaltimetype t);
112
113/* Create a new time, given a day of year and a year. */
114struct icaltimetype icaltime_from_day_of_year(short doy, short year);
115
116/* Return the day of the week of the given time. Sunday is 1 */
117short icaltime_day_of_week(struct icaltimetype t);
118
119/* Return the day of the year for the Sunday of the week that the
120 given time is within. */
121short icaltime_start_doy_of_week(struct icaltimetype t);
122
123/* Return a string with the time represented in the same format as ctime(). THe string is owned by libical */
124char* icaltime_as_ctime(struct icaltimetype);
125
126/* Return the week number for the week the given time is within */
127short icaltime_week_number(struct icaltimetype t);
128
129/* Create a new time from a weeknumber and a year. */
130struct icaltimetype icaltime_from_week_number(short week_number, short year);
131
132/* Return -1, 0, or 1 to indicate that a<b, a==b or a>b */
133int icaltime_compare(struct icaltimetype a,struct icaltimetype b);
134
135/* like icaltime_compare, but only use the date parts. */
136int icaltime_compare_date_only(struct icaltimetype a, struct icaltimetype b);
137
138/* Return the number of days in the given month */
139short icaltime_days_in_month(short month,short year);
140
141
142#endif /* !ICALTIME_H */
143
144
145