#include "icalduration.h"
+#include <glib.h>
+
#include <assert.h>
#include <string.h>
#include <stdlib.h>
{
int dt = icaldurationtype_as_int(d);
+#ifdef G_OS_WIN32
+ GTimeZone *zone;
+ GDateTime *dtm;
+
+ if (t.is_utc == 1)
+ zone = g_time_zone_new_utc();
+ else
+ zone = g_time_zone_new_local();
+
+ dtm = g_date_time_new(
+ zone,
+ t.year,
+ t.month,
+ t.day,
+ t.hour,
+ t.minute,
+ t.second);
+
+ GDateTime *d2 = g_date_time_add_seconds(dtm, dt);
+
+ t.year = g_date_time_get_year(d2);
+ t.month = g_date_time_get_month(d2);
+ t.day = g_date_time_get_day_of_month(d2);
+ t.hour = g_date_time_get_hour(d2);
+ t.minute = g_date_time_get_minute(d2);
+ t.second = g_date_time_get_second(d2);
+
+ g_date_time_unref(dtm);
+ g_date_time_unref(d2);
+ g_time_zone_unref(zone);
+#else
t.second += dt;
t = icaltime_normalize(t);
-
+#endif
+
return t;
}
day, dd, mon, yyyy, hh, mm, ss, tzoffset(&t));
#else
GDateTime *dt = g_date_time_new_from_unix_local(t);
- gchar *buf2 = g_date_time_format(dt, "%a, %e %b %Y %H:%M:%S %Z");
+ gchar *buf2 = g_date_time_format(dt, "%a, %e %b %Y %H:%M:%S %z");
+ g_date_time_unref(dt);
strncpy(buf, buf2, len);
g_free(buf2);
#endif
gchar date[128];
time_t t;
struct tm lt;
- struct tm buft;
memset(subject, 0, sizeof(subject));
memset(date, 0, sizeof(date));
}
#ifndef G_OS_WIN32
+ struct tm buft;
lt = *localtime_r(&t, &buft);
#else
if (t < 0)
if (dtend && *(dtend)) {
time_t tmp = icaltime_as_timet((icaltime_from_string(dtend)));
+#ifdef G_OS_WIN32
+ GDateTime *dt = g_date_time_new_from_unix_local(tmp);
+ event->end = g_date_time_format(dt, "%a, %e %b %Y %H:%M:%S %z");
+ g_date_time_unref(dt);
+#else
gchar buft[512];
tzset();
event->end = g_strdup(ctime_r(&tmp, buft));
+#endif
}
if (dtstart && *(dtstart)) {
time_t tmp = icaltime_as_timet((icaltime_from_string(dtstart)));
+#ifdef G_OS_WIN32
+ GDateTime *dt = g_date_time_new_from_unix_local(tmp);
+ event->start = g_date_time_format(dt, "%a, %e %b %Y %H:%M:%S %z");
+ g_date_time_unref(dt);
+#else
gchar buft[512];
tzset();
event->start = g_strdup(ctime_r(&tmp, buft));
+#endif
}
event->dtstart = g_strdup(dtstart?dtstart:"");
event->dtend = g_strdup(dtend?dtend:"");
struct tm evtstart, today;
time_t evtstart_t, today_t;
struct icaltimetype itt;
- struct tm buft;
tzset();
}
#ifndef G_OS_WIN32
+ struct tm buft;
today = *localtime_r(&today_t, &buft);
localtime_r(&evtstart_t, &evtstart);
#else