示例#1
0
void
dates_date_changed_cb (DatesView *view, DatesData *d)
{
    struct tm timem;
    gchar buffer[256];
    gchar *buffer_utf8;

    const icaltimetype *date = dates_view_get_date (view);
#ifndef WITH_HILDON
    gchar *text;
#endif

    timem = icaltimetype_to_tm ((icaltimetype *)date);
    strftime (buffer, 255, "%A, %x", &timem);

#ifdef WITH_HILDON
    gtk_window_set_title (GTK_WINDOW (d->main_window), buffer);
#else
    text = g_strdup_printf ("%s - %s", buffer, _("Dates"));
    gtk_window_set_title (GTK_WINDOW (d->main_window), text);
    g_free (text);
#endif

    strftime (buffer, 255, "<big><b>%A %d %B, %Y</b></big>", &timem);
    buffer_utf8 = g_locale_to_utf8(buffer, -1,
		NULL, NULL, NULL);
    gtk_label_set_markup (GTK_LABEL (d->header_label), buffer_utf8);
    g_free (buffer_utf8);
}
示例#2
0
static void
add_time_to_rdf (xmlNodePtr node,
                 const gchar *tag,
                 icaltimetype *time)
{
	if (time) {
		xmlNodePtr cur_node = NULL;
		struct tm mytm = icaltimetype_to_tm (time);
		gchar *str = (gchar *) g_malloc (sizeof (gchar) * 200);
		gchar *tmp = NULL;
		gchar *timezone;
		/*
		 * Translator: the %FT%T is the thirth argument for a strftime function.
		 * It lets you define the formatting of the date in the rdf-file.
		 * Also check out http://www.w3.org/2002/12/cal/tzd
		 * */
		e_utf8_strftime (str, 200, _("%FT%T"), &mytm);

		cur_node = xmlNewChild (node, NULL, (guchar *) tag, (guchar *) str);

		/* Not sure about this property */
		timezone = calendar_config_get_timezone ();
		tmp = g_strdup_printf ("http://www.w3.org/2002/12/cal/tzd/%s#tz", timezone);
		xmlSetProp (cur_node, (const guchar *)"rdf:datatype", (guchar *) tmp);
		g_free (tmp);
		g_free (timezone);
		g_free (str);
	}
}
示例#3
0
static GString *
add_time_to_csv (GString *line,
                 icaltimetype *time,
                 CsvConfig *config)
{

	if (time) {
		gboolean needquotes = FALSE;
		struct tm mytm = icaltimetype_to_tm (time);
		gchar *str = (gchar *) g_malloc (sizeof (gchar) * 200);

		/* Translators: the %F %T is the third argument for a
		 * strftime function.  It lets you define the formatting
		 * of the date in the csv-file. */
		e_utf8_strftime (str, 200, _("%F %T"), &mytm);

		needquotes = string_needsquotes (str, config);

		if (needquotes)
			line = g_string_append (line, config->quote);

		line = g_string_append (line, str);

		if (needquotes)
			line = g_string_append (line, config->quote);

		g_free (str);

	}

	line = g_string_append (line, config->delimiter);

	return line;
}
示例#4
0
static gchar *
format_dt (const ECalComponentDateTime *dt,
           GHashTable *timezones,
           icaltimezone *users_zone)
{
	struct tm tm;

	g_return_val_if_fail (dt != NULL, NULL);
	g_return_val_if_fail (timezones != NULL, NULL);

	if (!dt->value)
		return NULL;

	dt->value->zone = NULL;
	if (dt->tzid) {
		dt->value->zone = g_hash_table_lookup (timezones, dt->tzid);
		if (!dt->value->zone)
			dt->value->zone = icaltimezone_get_builtin_timezone_from_tzid (dt->tzid);

		if (!dt->value->zone && g_ascii_strcasecmp (dt->tzid, "UTC") == 0)
			dt->value->zone = icaltimezone_get_utc_timezone ();
	}

	if (dt->value->zone)
		tm = icaltimetype_to_tm_with_zone (dt->value, (icaltimezone *) dt->value->zone, users_zone);
	else
		tm = icaltimetype_to_tm (dt->value);

	return e_datetime_format_format_tm ("calendar", "table", dt->value->is_date ? DTFormatKindDate : DTFormatKindDateTime, &tm);
}
/* 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);
}
示例#6
0
static void
event_time (icalcomponent * icalcomp, gchar * str, size_t len,
			DNTimeFormat format)
{
	struct icaltimetype istart, iend;
	struct tm tm_start, tm_end;
	
	istart = icalcomponent_get_dtstart (icalcomp);
	iend   = icalcomponent_get_dtend (icalcomp);

	tm_start = icaltimetype_to_tm (&istart);
	tm_end   = icaltimetype_to_tm (&iend);

	gint offset = 0;
	
	if (format == DN_TimeOnly)
	{
		offset = e_utf8_strftime (str, len, "%R", &tm_start);
		str += offset;

		*str++ = ' ';
		*str++ = '-';
		*str++ = ' ';
		
		len -= (offset + 3);
		g_assert (len > 0);
		
		e_utf8_strftime (str, len, "%R", &tm_end);
	}
	else
	{
		offset = e_utf8_strftime (str, len, "%x", &tm_start);
		str += offset;
		*str++ = ' ';
		*str++ = ' ';
		len -= (offset + 2);
		g_assert (len > 0);
		
		offset = e_utf8_strftime (str, len, "%R", &tm_start);
		str += offset;
		*str++ = '-';
		len -= (offset + 1);
		g_assert (len > 0);

		e_utf8_strftime (str, len, "%R", &tm_end);
	}
}
示例#7
0
void
dates_details_update_time_label (DatesData *d, GtkWidget *label,
				 struct icaltimetype *time)
{
    struct tm timem;
    gchar time_text[256];

    timem = icaltimetype_to_tm (time);
    strftime (time_text, 255, TIME_MARKUP, &timem);
    gtk_label_set_markup (GTK_LABEL (label), time_text);
}
示例#8
0
/* Converts a time_t to a string, relative to the specified timezone */
gchar *
timet_to_str_with_zone (time_t t,
                        icaltimezone *zone,
			gboolean date_only)
{
	struct icaltimetype itt;
	struct tm tm;

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

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

	return e_datetime_format_format_tm ("calendar", "table", date_only ? DTFormatKindDate : DTFormatKindDateTime, &tm);
}
static struct tm
cal_shell_view_get_current_time (ECalendarItem *calitem,
                                 ECalShellView *cal_shell_view)
{
	ECalShellContent *cal_shell_content;
	struct icaltimetype tt;
	icaltimezone *timezone;
	ECalModel *model;

	cal_shell_content = cal_shell_view->priv->cal_shell_content;
	model = e_cal_base_shell_content_get_model (E_CAL_BASE_SHELL_CONTENT (cal_shell_content));
	timezone = e_cal_model_get_timezone (model);

	tt = icaltime_from_timet_with_zone (time (NULL), FALSE, timezone);

	return icaltimetype_to_tm (&tt);
}
示例#10
0
static struct tm
annum_shell_view_get_current_time (ECalendarItem * calitem,
				    AnnumShellView * prox_shell_view)
{
	AnnumShellContent *prox_shell_content;
	struct icaltimetype tt;
	icaltimezone *timezone;
	ECalModel *model;

	prox_shell_content = prox_shell_view->priv->prox_shell_content;
	model = annum_shell_content_get_model (prox_shell_content);
	timezone = e_cal_model_get_timezone (model);

	tt = icaltime_from_timet_with_zone (time (NULL), FALSE, timezone);

	return icaltimetype_to_tm (&tt);
}
示例#11
0
/* 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);
}
/**
 * icaltimetype_to_tm_with_zone:
 * @itt: A time value.
 * @from_zone: Source timezone.
 * @to_zone: Destination timezone.
 *
 * Converts a time value from one timezone to another, and returns a struct tm
 * representation of the time.
 *
 * Return value: The converted time as a struct tm. All fields will be
 * set properly except for tm.tm_yday.
 **/
struct tm
icaltimetype_to_tm_with_zone (struct icaltimetype *itt,
			      icaltimezone *from_zone,
			      icaltimezone *to_zone)
{
	struct tm tm;
	struct icaltimetype itt_copy;

	memset (&tm, 0, sizeof (tm));
	tm.tm_isdst = -1;

	g_return_val_if_fail (itt != NULL, tm);

	itt_copy = *itt;

	icaltimezone_convert_time (&itt_copy, from_zone, to_zone);
	tm = icaltimetype_to_tm (&itt_copy);

	return tm;
}
示例#13
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)
{
	struct icaltimetype itt;
	icaltimezone *zone = NULL;
	struct tm tm;

	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);

	return e_datetime_format_format_tm ("calendar", "table", itt.is_date ? DTFormatKindDate : DTFormatKindDateTime, &tm);
}