Show readable time in the commit list

This commit is contained in:
Ignacio Casal Quinteiro 2013-03-17 18:40:38 +01:00
parent 14a44e3d54
commit 6531c14d34
3 changed files with 40 additions and 5 deletions

View file

@ -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)
{

View file

@ -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");
}

View file

@ -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>