convert from a time_t to an icaldurationtype.

* src/libical/icaltypes.c (icaldurationtype_from_timet): convert
	from a time_t to an icaldurationtype.

svn path=/trunk/; revision=2589
This commit is contained in:
Seth Alves
2000-04-24 20:07:19 +00:00
parent 33f48d299e
commit de46951fcf
2 changed files with 24 additions and 0 deletions
+5
View File
@@ -1,3 +1,8 @@
2000-04-24 Seth Alves <alves@hungry.com>
* src/libical/icaltypes.c (icaldurationtype_from_timet): convert
from a time_t to an icaldurationtype.
2000-03-17 Eric Busboom <eric@agony.qualcomm.com>
* icalstore.c Vastly improved icalstore_test.
+19
View File
@@ -193,6 +193,25 @@ time_t icaldurationtype_as_timet(struct icaldurationtype dur)
}
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;
}
void icalrecurrencetype_clear(struct icalrecurrencetype *recur)
{
memset(recur,ICAL_RECURRENCE_ARRAY_MAX_BYTE,