dect
/
asterisk
Archived
13
0
Fork 0

Fix handling of floating times and dates

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@223449 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
twilson 2009-10-10 20:02:32 +00:00
parent 5febdf2d83
commit 5f0f1093db
2 changed files with 59 additions and 8 deletions

View File

@ -297,6 +297,31 @@ static struct ast_str *caldav_get_events_between(struct caldav_pvt *pvt, time_t
return response;
}
static time_t icalfloat_to_timet(icaltimetype time)
{
struct ast_tm tm = {0,};
struct timeval tv;
tm.tm_mday = time.day;
tm.tm_mon = time.month - 1;
tm.tm_year = time.year - 1900;
tm.tm_hour = time.hour;
tm.tm_min = time.minute;
tm.tm_sec = time.second;
tm.tm_isdst = -1;
tv = ast_mktime(&tm, NULL);
return tv.tv_sec;
}
/* span->start & span->end may be dates or floating times which have no timezone,
* which would mean that they should apply to the local timezone for all recepients.
* For example, if a meeting was set for 1PM-2PM floating time, people in different time
* zones would not be scheduled at the same local times. Dates are often treated as
* floating times, so all day events will need to be converted--so we can trust the
* span here, and instead will grab the start and end from the component, which will
* allow us to test for floating times or dates.
*/
static void caldav_add_event(icalcomponent *comp, struct icaltime_span *span, void *data)
{
struct caldav_pvt *pvt = data;
@ -317,11 +342,11 @@ static void caldav_add_event(icalcomponent *comp, struct icaltime_span *span, vo
return;
}
start = icaltime_from_timet_with_zone(span->start, 0, utc);
end = icaltime_from_timet_with_zone(span->end, 0, utc);
event->start = span->start;
event->end = span->end;
start = icalcomponent_get_dtstart(comp);
end = icalcomponent_get_dtend(comp);
event->start = icaltime_get_tzid(start) ? span->start : icalfloat_to_timet(start);
event->end = icaltime_get_tzid(end) ? span->end : icalfloat_to_timet(end);
event->busy_state = span->is_busy ? AST_CALENDAR_BS_BUSY : AST_CALENDAR_BS_FREE;
if ((prop = icalcomponent_get_first_property(comp, ICAL_SUMMARY_PROPERTY))) {

View File

@ -160,6 +160,32 @@ static icalcomponent *fetch_icalendar(struct icalendar_pvt *pvt)
return comp;
}
static time_t icalfloat_to_timet(icaltimetype time)
{
struct ast_tm tm = {0,};
struct timeval tv;
tm.tm_mday = time.day;
tm.tm_mon = time.month - 1;
tm.tm_year = time.year - 1900;
tm.tm_hour = time.hour;
tm.tm_min = time.minute;
tm.tm_sec = time.second;
tm.tm_isdst = -1;
tv = ast_mktime(&tm, NULL);
return tv.tv_sec;
}
/* span->start & span->end may be dates or floating times which have no timezone,
* which would mean that they should apply to the local timezone for all recepients.
* For example, if a meeting was set for 1PM-2PM floating time, people in different time
* zones would not be scheduled at the same local times. Dates are often treated as
* floating times, so all day events will need to be converted--so we can trust the
* span here, and instead will grab the start and end from the component, which will
* allow us to test for floating times or dates.
*/
static void icalendar_add_event(icalcomponent *comp, struct icaltime_span *span, void *data)
{
struct icalendar_pvt *pvt = data;
@ -180,11 +206,11 @@ static void icalendar_add_event(icalcomponent *comp, struct icaltime_span *span,
return;
}
start = icaltime_from_timet_with_zone(span->start, 0, utc);
end = icaltime_from_timet_with_zone(span->end, 0, utc);
event->start = span->start;
event->end = span->end;
start = icalcomponent_get_dtstart(comp);
end = icalcomponent_get_dtend(comp);
event->start = icaltime_get_tzid(start) ? span->start : icalfloat_to_timet(start);
event->end = icaltime_get_tzid(end) ? span->end : icalfloat_to_timet(end);
event->busy_state = span->is_busy ? AST_CALENDAR_BS_BUSY : AST_CALENDAR_BS_FREE;
if ((prop = icalcomponent_get_first_property(comp, ICAL_SUMMARY_PROPERTY))) {