summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-file.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnautilus-private/nautilus-file.c')
-rw-r--r--libnautilus-private/nautilus-file.c111
1 files changed, 55 insertions, 56 deletions
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index b4a9fca05..4c618250f 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -4657,26 +4657,6 @@ nautilus_file_get_trash_original_file_parent_as_string (NautilusFile *file)
return NULL;
}
-/*
- * Note to localizers: You can look at man strftime
- * for details on the format, but you should only use
- * the specifiers from the C standard, not extensions.
- * These include "%" followed by one of
- * "aAbBcdHIjmMpSUwWxXyYZ". There are two extensions
- * in the Nautilus version of strftime that can be
- * used (and match GNU extensions). Putting a "-"
- * between the "%" and any numeric directive will turn
- * off zero padding, and putting a "_" there will use
- * space padding instead of zero padding.
- */
-#define TODAY_TIME_FORMAT_24 N_("%R")
-#define TODAY_TIME_FORMAT N_("%-I:%M %P")
-#define THIS_MONTH_TIME_FORMAT N_("%b %-e")
-#define THIS_YEAR_TIME_FORMAT N_("%b %-e")
-#define ANYTIME_TIME_FORMAT N_("%b %-d %Y")
-#define FULL_FORMAT N_("%a, %b %e %Y %I:%M:%S %p")
-#define FULL_FORMAT_24 N_("%a, %b %e %Y %T")
-
/**
* nautilus_file_get_date_as_string:
*
@@ -4688,49 +4668,68 @@ nautilus_file_get_trash_original_file_parent_as_string (NautilusFile *file)
*
**/
static char *
-nautilus_file_get_date_as_string (NautilusFile *file, NautilusDateType date_type, gboolean compact)
+nautilus_file_get_date_as_string (NautilusFile *file,
+ NautilusDateType date_type,
+ gboolean full_date)
{
time_t file_time_raw;
- const char *format;
- char *result = NULL;
- GDateTime *date_time, *today;
- int y, m, d;
- int y_now, m_now, d_now;
- GDesktopClockFormat value;
+ GDateTime *file_date, *now;
+ gint daysAgo;
gboolean use_24;
+ gchar *format;
+ gchar *result;
- if (!nautilus_file_get_date (file, date_type, &file_time_raw)) {
+ if (!nautilus_file_get_date (file, date_type, &file_time_raw))
return NULL;
- }
- date_time = g_date_time_new_from_unix_local (file_time_raw);
+ file_date = g_date_time_new_from_unix_local (file_time_raw);
+ if (!full_date) {
+ now = g_date_time_new_now_local ();
- g_date_time_get_ymd (date_time, &y, &m, &d);
+ daysAgo = g_date_time_difference (now, file_date) / (24 * 60 * 60 * 1000 * 1000L);
- today = g_date_time_new_now_local ();
- g_date_time_get_ymd (today, &y_now, &m_now, &d_now);
- g_date_time_unref (today);
+ use_24 = g_settings_get_enum (gnome_interface_preferences, "clock-format") ==
+ G_DESKTOP_CLOCK_FORMAT_24H;
- value = g_settings_get_enum (gnome_interface_preferences, "clock-format");
- use_24 = value == G_DESKTOP_CLOCK_FORMAT_24H;
-
- if (!compact) {
- format = use_24 ? FULL_FORMAT_24 : FULL_FORMAT;
- } else if (y == y_now && m == m_now && d == d_now) {
- format = use_24 ? TODAY_TIME_FORMAT_24 : TODAY_TIME_FORMAT;
- } else if (y == y_now && m == m_now) {
- format = THIS_MONTH_TIME_FORMAT;
- } else if (y == y_now) {
- format = THIS_YEAR_TIME_FORMAT;
+ // Show only the time if date is on today
+ if (daysAgo < 1) {
+ if (use_24) {
+ /* Translators: Time in 24h format */
+ format = N_("%H\u2236%M");
+ } else {
+ /* Translators: Time in 12h format */
+ format = N_("%l\u2236%M %p");
+ }
+ }
+ // Show the word "Yesterday" and time if date is on yesterday
+ else if (daysAgo < 2) {
+ // xgettext:no-c-format
+ format = N_("Yesterday");
+ }
+ // Show a week day and time if date is in the last week
+ else if (daysAgo < 7) {
+ /* Translators: this is the week day name. i.e. "Monday" */
+ // xgettext:no-c-format
+ format = N_("%a");
+ } else if (g_date_time_get_year (file_date) == g_date_time_get_year (now)) {
+ /* Translators: this is the day of the month plus the short
+ * month name i.e. "3 Feb" */
+ // xgettext:no-c-format
+ format = N_("%-e %b");
+ } else {
+ /* Translators: this is the day of the month plus the short
+ * month name plus the year i.e. "25 Feb 2015" */
+ // xgettext:no-c-format
+ format = N_("%-e %b %Y");
+ }
} else {
- format = ANYTIME_TIME_FORMAT;
+ format = N_("%c");
}
- result = g_date_time_format (date_time, _(format));
-
- g_date_time_unref (date_time);
+ result = g_date_time_format (file_date, format);
+ g_date_time_unref (file_date);
- return result;
+ return result;
}
static void
@@ -6188,32 +6187,32 @@ nautilus_file_get_string_attribute_q (NautilusFile *file, GQuark attribute_q)
if (attribute_q == attribute_date_modified_q) {
return nautilus_file_get_date_as_string (file,
NAUTILUS_DATE_TYPE_MODIFIED,
- TRUE);
+ FALSE);
}
if (attribute_q == attribute_date_modified_full_q) {
return nautilus_file_get_date_as_string (file,
NAUTILUS_DATE_TYPE_MODIFIED,
- FALSE);
+ TRUE);
}
if (attribute_q == attribute_date_accessed_q) {
return nautilus_file_get_date_as_string (file,
NAUTILUS_DATE_TYPE_ACCESSED,
- TRUE);
+ FALSE);
}
if (attribute_q == attribute_date_accessed_full_q) {
return nautilus_file_get_date_as_string (file,
NAUTILUS_DATE_TYPE_ACCESSED,
- FALSE);
+ TRUE);
}
if (attribute_q == attribute_trashed_on_q) {
return nautilus_file_get_date_as_string (file,
NAUTILUS_DATE_TYPE_TRASHED,
- TRUE);
+ FALSE);
}
if (attribute_q == attribute_trashed_on_full_q) {
return nautilus_file_get_date_as_string (file,
NAUTILUS_DATE_TYPE_TRASHED,
- FALSE);
+ TRUE);
}
if (attribute_q == attribute_permissions_q) {
return nautilus_file_get_permissions_as_string (file);