コード例 #1
0
ファイル: rdf-format.c プロジェクト: UIKit0/evolution
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);
	}
}
コード例 #2
0
ファイル: csv-format.c プロジェクト: UIKit0/evolution
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;
}
コード例 #3
0
/* FIXME: We need to set the "transient_for" property for the dialog. */
static void
show_date_warning (ECellDateEditText *ecd)
{
	GtkWidget *dialog;
	gchar buffer[64], *format;
	time_t t;
	struct tm *tmp_tm;

	t = time (NULL);
	/* We are only using this as an example, so the timezone doesn't
	 * matter. */
	tmp_tm = localtime (&t);

	if (e_cell_date_edit_text_get_use_24_hour_format (ecd))
		/* strftime format of a weekday, a date and a time, 24-hour. */
		format = _("%a %m/%d/%Y %H:%M:%S");
	else
		/* strftime format of a weekday, a date and a time, 12-hour. */
		format = _("%a %m/%d/%Y %I:%M:%S %p");

	e_utf8_strftime (buffer, sizeof (buffer), format, tmp_tm);

	dialog = gtk_message_dialog_new (
		NULL, 0,
		GTK_MESSAGE_ERROR,
		GTK_BUTTONS_OK,
		_("The date must be entered in the format: \n%s"),
		buffer);
	gtk_dialog_run (GTK_DIALOG (dialog));
	gtk_widget_destroy (dialog);
}
コード例 #4
0
ファイル: dates_navigator.c プロジェクト: GNOME/dates
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);
	}
}
コード例 #5
0
/* Returns TRUE if the locale has 'am' and 'pm' strings defined, in which
 * case the user can choose between 12 and 24-hour time formats. */
gboolean
calendar_config_locale_supports_12_hour_format (void)
{
	gchar s[16];
	time_t t = 0;

	calendar_config_init ();

	e_utf8_strftime (s, sizeof s, "%p", gmtime (&t));
	return s[0] != '\0';
}