diff options
Diffstat (limited to 'libical/src/libical/icaltypes.c')
-rw-r--r-- | libical/src/libical/icaltypes.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/libical/src/libical/icaltypes.c b/libical/src/libical/icaltypes.c index 25e0e12b48..b60333887e 100644 --- a/libical/src/libical/icaltypes.c +++ b/libical/src/libical/icaltypes.c @@ -192,26 +192,25 @@ time_t icaldurationtype_as_timet(struct icaldurationtype dur) (60 * 60 * 24 * 7 * dur.weeks)); } - +/* From Seth Alves, <alves@hungry.com> */ struct icaldurationtype icaldurationtype_from_timet(time_t t) { - struct icaldurationtype dur; - time_t used = 0; - - dur.weeks = (t - used) / (60 * 60 * 24 * 7); - used += dur.weeks * (60 * 60 * 24 * 7); - dur.days = (t - used) / (60 * 60 * 24); - used += dur.days * (60 * 60 * 24); - dur.hours = (t - used) / (60 * 60); - used += dur.hours * (60 * 60); - dur.minutes = (t - used) / (60); - used += dur.minutes * (60); - dur.seconds = (t - used); - - return dur; -} - - + struct icaldurationtype dur; + time_t used = 0; + + dur.weeks = (t - used) / (60 * 60 * 24 * 7); + used += dur.weeks * (60 * 60 * 24 * 7); + dur.days = (t - used) / (60 * 60 * 24); + used += dur.days * (60 * 60 * 24); + dur.hours = (t - used) / (60 * 60); + used += dur.hours * (60 * 60); + dur.minutes = (t - used) / (60); + used += dur.minutes * (60); + dur.seconds = (t - used); + + return dur; +} + void icalrecurrencetype_clear(struct icalrecurrencetype *recur) { memset(recur,ICAL_RECURRENCE_ARRAY_MAX_BYTE, |