diff options
author | Jonathan Kang <jonathan121537@gmail.com> | 2015-11-24 16:08:04 +0800 |
---|---|---|
committer | Jonathan Kang <jonathan121537@gmail.com> | 2015-11-24 19:32:19 +0800 |
commit | 7be737823778605a0f347849849aa926148e44b5 (patch) | |
tree | 4b590bec1996598bbd3f2f947b153c2b24df97f9 | |
parent | ff85a748693bcdb9222e85de8677da9d488f1938 (diff) | |
download | gnome-logs-7be737823778605a0f347849849aa926148e44b5.tar.gz |
Show seconds in details view and exported logs
https://bugzilla.gnome.org/show_bug.cgi?id=758108
-rw-r--r-- | src/gl-eventviewdetail.c | 2 | ||||
-rw-r--r-- | src/gl-eventviewlist.c | 2 | ||||
-rw-r--r-- | src/gl-eventviewrow.c | 2 | ||||
-rw-r--r-- | src/gl-util.c | 125 | ||||
-rw-r--r-- | src/gl-util.h | 3 |
5 files changed, 105 insertions, 29 deletions
diff --git a/src/gl-eventviewdetail.c b/src/gl-eventviewdetail.c index b86ce01..ab85f30 100644 --- a/src/gl-eventviewdetail.c +++ b/src/gl-eventviewdetail.c @@ -124,7 +124,7 @@ gl_event_view_detail_create_detail (GlEventViewDetail *detail) now = g_date_time_new_now_local (); str = gl_util_timestamp_to_display (gl_journal_entry_get_timestamp (entry), now, - priv->clock_format); + priv->clock_format, TRUE); g_date_time_unref (now); gtk_label_set_text (GTK_LABEL (priv->time_label), str); g_free (str); diff --git a/src/gl-eventviewlist.c b/src/gl-eventviewlist.c index 05dc4fe..0925173 100644 --- a/src/gl-eventviewlist.c +++ b/src/gl-eventviewlist.c @@ -100,7 +100,7 @@ gl_event_view_list_get_output_logs (GlEventViewList *view) timestamp = gl_event_view_row_get_timestamp (GL_EVENT_VIEW_ROW (row)); now = g_date_time_new_now_local (); time = gl_util_timestamp_to_display (timestamp, now, - priv->clock_format); + priv->clock_format, TRUE); output_text = g_strconcat (time, " ", comm ? comm : "kernel", ": ", diff --git a/src/gl-eventviewrow.c b/src/gl-eventviewrow.c index ce4977b..5ff42b7 100644 --- a/src/gl-eventviewrow.c +++ b/src/gl-eventviewrow.c @@ -273,7 +273,7 @@ gl_event_view_row_constructed (GObject *object) now = g_date_time_new_now_local (); time = gl_util_timestamp_to_display (gl_journal_entry_get_timestamp (entry), - now, priv->clock_format); + now, priv->clock_format, FALSE); g_date_time_unref (now); priv->time_label = gtk_label_new (time); context = gtk_widget_get_style_context (GTK_WIDGET (priv->time_label)); diff --git a/src/gl-util.c b/src/gl-util.c index 0e15662..d21fefc 100644 --- a/src/gl-util.c +++ b/src/gl-util.c @@ -117,7 +117,8 @@ compare_timestamps (GDateTime *a, gchar * gl_util_timestamp_to_display (guint64 microsecs, GDateTime *now, - GlUtilClockFormat format) + GlUtilClockFormat format, + gboolean show_second) { GDateTime *datetime; GDateTime *local; @@ -139,21 +140,59 @@ gl_util_timestamp_to_display (guint64 microsecs, switch (compare_timestamps (local, now)) { case GL_UTIL_TIMESTAMPS_SAME_DAY: - /* Translators: timestamp format for events on the current - * day, showing the time in 12-hour format. */ - time = g_date_time_format (local, _("%l:%M %p")); + if (show_second) + { + /* Translators: timestamp format for events on the + * current day, showing the time with seconds in + * 12-hour format. */ + time = g_date_time_format (local, _("%l:%M:%S %p")); + } + else + { + /* Translators: timestamp format for events on the + * current day, showing the time without seconds in + * 12-hour format. */ + time = g_date_time_format (local, _("%l:%M %p")); + } break; case GL_UTIL_TIMESTAMPS_SAME_YEAR: - /* Translators: timestamp format for events in the current - * year, showing the abbreviated month name, day of the - * month and the time in 12-hour format. */ - time = g_date_time_format (local, _("%b %e %l:%M %p")); + if (show_second) + { + /* Translators: timestamp format for events in the + * current year, showing the abbreviated month name, + * day of the month and the time with seconds in + * 12-hour format. */ + time = g_date_time_format (local, + _("%b %e %l:%M:%S %p")); + } + else + { + /* Translators: timestamp format for events in the + * current year, showing the abbreviated month name, + * day of the month and the time without seconds in + * 12-hour format. */ + time = g_date_time_format (local, _("%b %e %l:%M %p")); + } break; case GL_UTIL_TIMESTAMPS_DIFFERENT_YEAR: - /* Translators: timestamp format for events in a different - * year, showing the abbreviated month name, day of the - * month, year and the time in 12-hour format. */ - time = g_date_time_format (local, _("%b %e %Y %l:%M %p")); + if (show_second) + { + /* Translators: timestamp format for events in a + * different year, showing the abbreviated month name, + * day of the month, year and the time with seconds + * in 12-hour format. */ + time = g_date_time_format (local, + _("%b %e %Y %l:%M:%S %p")); + } + else + { + /* Translators: timestamp format for events in a + * different year, showing the abbreviated month name, + * day of the month, year and the time without seconds + * in 12-hour format. */ + time = g_date_time_format (local, + _("%b %e %Y %l:%M %p")); + } break; default: g_assert_not_reached (); @@ -164,21 +203,57 @@ gl_util_timestamp_to_display (guint64 microsecs, switch (compare_timestamps (local, now)) { case GL_UTIL_TIMESTAMPS_SAME_DAY: - /* Translators: timestamp format for events on the current - * day, showing the time in 24-hour format. */ - time = g_date_time_format (local, _("%H:%M")); + if (show_second) + { + /* Translators: timestamp format for events on the + * current day, showing the time with seconds in + * 24-hour format. */ + time = g_date_time_format (local, _("%H:%M:%S")); + } + else + { + /* Translators: timestamp format for events on the + * current day, showing the time without seconds in + * 24-hour format. */ + time = g_date_time_format (local, _("%H:%M")); + } break; case GL_UTIL_TIMESTAMPS_SAME_YEAR: - /* Translators: timestamp format for events in the current - * year, showing the abbreviated month name, day of the - * month and the time in 24-hour format. */ - time = g_date_time_format (local, _("%b %e %H:%M")); + if (show_second) + { + /* Translators: timestamp format for events in the + * current year, showing the abbreviated month name, + * day of the month and the time with seconds in + * 24-hour format. */ + time = g_date_time_format (local, _("%b %e %H:%M:%S")); + } + else + { + /* Translators: timestamp format for events in the + * current year, showing the abbreviated month name, + * day of the month and the time without seconds in + * 24-hour format. */ + time = g_date_time_format (local, _("%b %e %H:%M")); + } break; case GL_UTIL_TIMESTAMPS_DIFFERENT_YEAR: - /* Translators: timestamp format for events in a different - * year, showing the abbreviated month name, day of the - * month, year and the time in 24-hour format. */ - time = g_date_time_format (local, _("%b %e %Y %H:%M")); + if (show_second) + { + /* Translators: timestamp format for events in a + * different year, showing the abbreviated month name, + * day of the month, year and the time with seconds + * in 24-hour format. */ + time = g_date_time_format (local, + _("%b %e %Y %H:%M:%S")); + } + else + { + /* Translators: timestamp format for events in a + * different year, showing the abbreviated month name, + * day of the month, year and the time without seconds + * in 24-hour format. */ + time = g_date_time_format (local, _("%b %e %Y %H:%M")); + } break; default: g_assert_not_reached (); @@ -234,9 +309,9 @@ gl_util_boot_time_to_display (guint64 realtime_first, now = g_date_time_new_now_local (); time_first = gl_util_timestamp_to_display (realtime_first, - now, clock_format); + now, clock_format, FALSE); time_last = gl_util_timestamp_to_display (realtime_last, - now, clock_format); + now, clock_format, FALSE); /* Transltors: the first string is the earliest timestamp of the boot, * and the second string is the newest timestamp. An example string might diff --git a/src/gl-util.h b/src/gl-util.h index a70910f..bbe1a2c 100644 --- a/src/gl-util.h +++ b/src/gl-util.h @@ -41,7 +41,8 @@ void gl_util_on_css_provider_parsing_error (GtkCssProvider *provider, G_GNUC_UNUSED gpointer user_data); gchar * gl_util_timestamp_to_display (guint64 microsecs, GDateTime *now, - GlUtilClockFormat format); + GlUtilClockFormat format, + gboolean show_second); gint gl_util_get_uid (void); gchar * gl_util_boot_time_to_display (guint64 timestamp_first, guint64 timestamp_last); |