[gitg] Show readable time in the commit list
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Show readable time in the commit list
- Date: Sun, 17 Mar 2013 17:47:22 +0000 (UTC)
commit 6531c14d3495c719c5822e1a55d4dc078c46f3ca
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sun Mar 17 18:40:38 2013 +0100
Show readable time in the commit list
libgitg-gtk/resources/diff-view.js | 4 +-
libgitg/gitg-commit.vala | 35 +++++++++++++++++++++++++++++
plugins/history/resources/view-history.ui | 6 ++--
3 files changed, 40 insertions(+), 5 deletions(-)
---
diff --git a/libgitg-gtk/resources/diff-view.js b/libgitg-gtk/resources/diff-view.js
index 85c40b7..027f9bd 100644
--- a/libgitg-gtk/resources/diff-view.js
+++ b/libgitg-gtk/resources/diff-view.js
@@ -222,7 +222,7 @@ function date_to_string(d)
}
else if (t < 3600)
{
- return "One hour ago";
+ return "An hour ago";
}
else if (t < 3600 * 12)
{
@@ -231,7 +231,7 @@ function date_to_string(d)
}
else if (t < 3600 * 24)
{
- return "One day ago";
+ return "A day ago";
}
else if (t < 3600 * 24 * 6)
{
diff --git a/libgitg/gitg-commit.vala b/libgitg/gitg-commit.vala
index 79de9e8..187d9ea 100644
--- a/libgitg/gitg-commit.vala
+++ b/libgitg/gitg-commit.vala
@@ -95,6 +95,41 @@ public class Commit : Ggit.Commit
private string date_for_display(DateTime dt)
{
+ var t = (new DateTime.now_local()).to_unix() - dt.to_unix();
+
+ if (t < 1)
+ {
+ return "Less than a second ago";
+ }
+ else if (t < 60)
+ {
+ return "Less than a minute ago";
+ }
+ else if (t < 600)
+ {
+ return "Less than 10 minutes ago";
+ }
+ else if (t < 1800)
+ {
+ return "Half an hour ago";
+ }
+ else if (t < 3600)
+ {
+ return "An hour ago";
+ }
+ else if (t < 3600 * 12)
+ {
+ return "%d hours ago".printf((int)Math.round(t / 3600));
+ }
+ else if (t < 3600 * 24)
+ {
+ return "A day ago";
+ }
+ else if (t < 3600 * 24 * 6)
+ {
+ return "%d days ago".printf((int)Math.round(t / (3600 * 24)));
+ }
+
return dt.format("%c");
}
diff --git a/plugins/history/resources/view-history.ui b/plugins/history/resources/view-history.ui
index a09c878..a7f1903 100644
--- a/plugins/history/resources/view-history.ui
+++ b/plugins/history/resources/view-history.ui
@@ -35,7 +35,7 @@
<property name="title" translatable="yes">Author</property>
<property name="sizing">fixed</property>
<property name="resizable">True</property>
- <property name="fixed-width">100</property>
+ <property name="fixed-width">200</property>
<child>
<object class="GtkCellRendererText" id="renderer_commit_list_author">
<property name="ellipsize">end</property>
@@ -46,7 +46,7 @@
</child>
</object>
</child>
- <!--<child>
+ <child>
<object class="GtkTreeViewColumn" id="column_commit_list_date">
<property name="title" translatable="yes">Date</property>
<property name="sizing">fixed</property>
@@ -61,7 +61,7 @@
</attributes>
</child>
</object>
- </child>-->
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]