コード例 #1
0
/* Converts a time_t to a string, relative to the specified timezone */
static gchar *
timet_to_str_with_zone (ECalComponentDateTime *dt,
                        ECalClient *client,
                        icaltimezone *default_zone,
                        gboolean use_24_hour_format)
{
	struct icaltimetype itt;
	icaltimezone *zone = NULL;
	struct tm tm;
	gchar buf[256];

	if (dt->tzid != NULL) {
		e_cal_client_get_timezone_sync (
			client, dt->tzid, &zone, NULL, NULL);
	} else if (dt->value->is_utc) {
		zone = icaltimezone_get_utc_timezone ();
	}

	itt = *dt->value;
	if (zone != NULL)
		icaltimezone_convert_time (&itt, zone, default_zone);
	tm = icaltimetype_to_tm (&itt);

	e_time_format_date_and_time (
		&tm, use_24_hour_format,
		FALSE, FALSE, buf, sizeof (buf));

	return g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
}
コード例 #2
0
ファイル: util.c プロジェクト: Distrotech/evolution
/* Converts a time_t to a string, relative to the specified timezone */
gchar *
timet_to_str_with_zone (time_t t,
                        icaltimezone *zone)
{
	struct icaltimetype itt;
	struct tm tm;
	gchar buf[256];

	if (t == -1)
		return g_strdup (_("invalid time"));

	itt = icaltime_from_timet_with_zone (t, FALSE, zone);
	tm = icaltimetype_to_tm (&itt);

	e_time_format_date_and_time (&tm, config_data_get_24_hour_format (),
				     FALSE, FALSE, buf, sizeof (buf));
	return g_strdup (buf);
}
コード例 #3
0
/* Builds a static string out of an exception date */
static gchar *
get_exception_string (EDateTimeList *date_time_list,
                      struct icaltimetype *itt)
{
	static gchar buf[256];
	struct icaltimetype tt;
	struct tm tmp_tm;
	icaltimezone *zone;
	gboolean use_24_hour_format;

	use_24_hour_format = e_date_time_list_get_use_24_hour_format (date_time_list);
	zone = e_date_time_list_get_timezone (date_time_list);

	tt = *itt;

	if (zone)
		tt = icaltime_convert_to_zone (tt, zone);

	tmp_tm.tm_year = tt.year - 1900;
	tmp_tm.tm_mon = tt.month - 1;
	tmp_tm.tm_mday = tt.day;
	tmp_tm.tm_hour = tt.hour;
	tmp_tm.tm_min = tt.minute;
	tmp_tm.tm_sec = tt.second;
	tmp_tm.tm_isdst = -1;

	tmp_tm.tm_wday = time_day_of_week (
		tt.day,
		tt.month - 1,
		tt.year);

	e_time_format_date_and_time (
		&tmp_tm, use_24_hour_format,
		FALSE, FALSE, buf, sizeof (buf));

	return buf;
}