How to get the Unixtime of an event?
Bastian Seeleib
bastian at seeleib.net
Sun Aug 14 14:46:27 PDT 2016
Thank you! The following now works (getting the unxtime in utc).
struct icaltimetype t = icalcomponent_get_dtstart(comp);
time_t tt = icaltime_as_timet_with_zone(t, icaltime_get_timezone(t));
printf("%ld", icaltime_as_timet(t)); = 1471933800
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);
time_t tt = icaltime_as_timet_with_zone(t, icaltime_get_timezone(t));
printf("%ld", icaltime_as_timet(t)); = 1471941000
Am 14.08.16 um 23:23 schrieb Ken Murchison:
> Try icaltime_as_timet_with_zone(). Are you trying to get localtime or
> UTC?
>
>
> On 8/14/16 4:15 PM, Bastian Seeleib wrote:
>> Hi all,
>>
>> i'm trying to get the unixtime of an event and having trouble with
>> it, could someone help me?
>> Using the follwing function calls, i'm getting 1471941000 which is 2
>> hours later than expected.
>>
>> icalproperty *pt = icalcomponent_get_first_property(comp,
>> ICAL_DTSTART_PROPERTY);
>> struct icaltimetype t = icalproperty_get_dtstart(pt);
>> printf("%ld", icaltime_as_timet(t));
>>
>> The dates are defined as following:
>>
>> DTSTART;TZID="Central Europe":20160823T083000
>> DTEND;TZID="Central Europe":20160823T103000
>>
>> The VTIMEZINE is set to:
>>
>> BEGIN:VTIMEZONE
>> TZID:Central Europe
>> BEGIN:STANDARD
>> DTSTART:19501029T020000
>> TZOFFSETFROM:+0200
>> TZOFFSETTO:+0100
>> RRULE:FREQ=YEARLY;BYMINUTE=0;BYHOUR=2;BYDAY=-1SU;BYMONTH=10
>> END:STANDARD
>> BEGIN:DAYLIGHT
>> DTSTART:19500326T020000
>> TZOFFSETFROM:+0100
>> TZOFFSETTO:+0200
>> RRULE:FREQ=YEARLY;BYMINUTE=0;BYHOUR=2;BYDAY=-1SU;BYMONTH=3
>> END:DAYLIGHT
>> END:VTIMEZONE
>>
>> To me it seems that the definition of VTIMEZONE is ignored.
>>
>>
>> _______________________________________________
>> 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