How to get the Unixtime of an event?

Bastian Seeleib bastian at seeleib.net
Tue Aug 16 13:55:30 PDT 2016


Thanks Milan.

The Code I've inserted was just an quickly written example which I 
hadn't actually run.
But I've used the same Function calls a few hours before (with the right 
variables).
Using icalcomponent_get_dtstart I'm now getting the right unixtime, so 
my problem is solved ;-).

I assume I just misunderstood the difference between 
icalproperty_get_dtstart() and icalcomponent_get_dtstart().
I presume icalproperty_get_dtstart() only gets the value of DTSTART 
without the TZID parameter, which in return means that the unixtime 
cannot include the timezone information.


Am 15.08.16 um 10:00 schrieb Milan Crha:
> 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
>
> _______________________________________________
> libical-devel mailing list
> libical-devel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/libical-devel




More information about the libical-devel mailing list