static void create_date_format_menu (GtkBuilder *builder) { GtkComboBoxText *combo_box; gchar *date_string; time_t now_raw; struct tm* now; combo_box = GTK_COMBO_BOX_TEXT (gtk_builder_get_object (builder, NEMO_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET)); now_raw = time (NULL); now = localtime (&now_raw); date_string = eel_strdup_strftime ("%c", now); gtk_combo_box_text_append_text (combo_box, date_string); g_free (date_string); date_string = eel_strdup_strftime ("%Y-%m-%d %H:%M:%S", now); gtk_combo_box_text_append_text (combo_box, date_string); g_free (date_string); date_string = eel_strdup_strftime (_("today at %-I:%M:%S %p"), now); gtk_combo_box_text_append_text (combo_box, date_string); g_free (date_string); }
static void create_date_format_menu (GladeXML *xml_dialog) { GtkWidget *combo_box; gchar *date_string; time_t now_raw; struct tm* now; combo_box = glade_xml_get_widget (xml_dialog, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET); now_raw = time (NULL); now = localtime (&now_raw); date_string = eel_strdup_strftime ("%c", now); gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string); g_free (date_string); date_string = eel_strdup_strftime ("%Y-%m-%d %H:%M:%S", now); gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string); g_free (date_string); date_string = eel_strdup_strftime (_("today at %-I:%M:%S %p"), now); gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string); g_free (date_string); }
/* Based on evolution/mail/message-list.c:filter_date() */ char * ephy_time_helpers_utf_friendly_time (time_t date) { time_t nowdate; time_t yesdate; struct tm then, now, yesterday; const char *format = NULL; char *str = NULL; gboolean done = FALSE; nowdate = time (NULL); if (date == 0) return NULL; localtime_r (&date, &then); localtime_r (&nowdate, &now); if (then.tm_mday == now.tm_mday && then.tm_mon == now.tm_mon && then.tm_year == now.tm_year) { /* Translators: "friendly time" string for the current day, strftime format. like "Today 12:34 am" */ format = _("Today %I:%M %p"); done = TRUE; } if (! done) { yesdate = nowdate - 60 * 60 * 24; localtime_r (&yesdate, &yesterday); if (then.tm_mday == yesterday.tm_mday && then.tm_mon == yesterday.tm_mon && then.tm_year == yesterday.tm_year) { /* Translators: "friendly time" string for the previous day, * strftime format. e.g. "Yesterday 12:34 am" */ format = _("Yesterday %I:%M %p"); done = TRUE; } } if (! done) { int i; for (i = 2; i < 7; i++) { yesdate = nowdate - 60 * 60 * 24 * i; localtime_r (&yesdate, &yesterday); if (then.tm_mday == yesterday.tm_mday && then.tm_mon == yesterday.tm_mon && then.tm_year == yesterday.tm_year) { /* Translators: "friendly time" string for a day in the current week, * strftime format. e.g. "Wed 12:34 am" */ format = _("%a %I:%M %p"); done = TRUE; break; } } } if (! done) { if (then.tm_year == now.tm_year) { /* Translators: "friendly time" string for a day in the current year, * strftime format. e.g. "Feb 12 12:34 am" */ format = _("%b %d %I:%M %p"); } else { /* Translators: "friendly time" string for a day in a different year, * strftime format. e.g. "Feb 12 1997" */ format = _("%b %d %Y"); } } if (format != NULL) { str = eel_strdup_strftime (format, &then); } if (str == NULL) { /* impossible time or broken locale settings */ str = g_strdup (_("Unknown")); } return str; }