How to get the Unixtime of an event?

Milan Crha mcrha at redhat.com
Mon Aug 15 01:00:34 PDT 2016


On Sun, 2016-08-14 at 23:46 +0200, Bastian Seeleib wrote:
> Strange that doing basicly the same with icalproperty_get_dtstart() 
> doesn't work:
> icalproperty *pt = icalcomponent_get_first_property(comp, 
> ICAL_DTSTART_PROPERTY);
> struct icaltimetype t = icalproperty_get_dtstart(comp);

	Hi,
there's a typo above, it should use 'pt', not 'comp'. The compiler
might tell you, thus I guess it's more about copy&paste error.

> time_t tt = icaltime_as_timet_with_zone(t, icaltime_get_timezone(t));

Verify that t.zone is set. Maybe it isn't in this case.

With my past experience, do not rely on the t.zone, it's not updated
when the parent component is freed, but it can be copied when you pass
the icaltimetype structure around in your code. It's safer to lookup
for the timezone on your own, based on the TZID parameter. It's a bit
more complicated code, of course.
	Bye,
	Milan



More information about the libical-devel mailing list