Fixed timestamp to date string conversion to be valid UTF-8 and

consistent (fixes bug #576685 and consequently debian bug #518705)
This commit is contained in:
Jesse van den Kieboom 2009-04-05 17:51:57 +02:00
parent f698110cf9
commit c5e8342da5
4 changed files with 19 additions and 29 deletions

View file

@ -163,18 +163,6 @@ tree_model_get_path(GtkTreeModel *tree_model, GtkTreeIter *iter)
return gtk_tree_path_new_from_indices(GPOINTER_TO_INT(iter->user_data), -1);
}
static gchar *
timestamp_to_str(guint64 timestamp)
{
time_t t = timestamp;
struct tm *tms = localtime(&t);
char buf[255];
strftime(buf, 255, "%c", tms);
return g_strdup(buf);
}
static void
tree_model_get_value(GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, GValue *value)
{
@ -203,7 +191,7 @@ tree_model_get_value(GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, G
g_value_set_string(value, gitg_revision_get_author(rv));
break;
case DATE_COLUMN:
g_value_take_string(value, timestamp_to_str(gitg_revision_get_timestamp(rv)));
g_value_take_string(value, gitg_utils_timestamp_to_str(gitg_revision_get_timestamp(rv)));
break;
default:
g_assert_not_reached();

View file

@ -693,20 +693,6 @@ update_diff(GitgRevisionView *self, GitgRepository *repository)
g_free(hash);
}
static gchar *
format_date(GitgRevision *revision)
{
guint64 timestamp = gitg_revision_get_timestamp(revision);
time_t t = timestamp;
char *ptr = ctime(&t);
// Remove newline?
ptr[strlen(ptr) - 1] = '\0';
return ptr;
}
void
gitg_revision_view_update(GitgRevisionView *self, GitgRepository *repository, GitgRevision *revision)
{
@ -726,7 +712,9 @@ gitg_revision_view_update(GitgRevisionView *self, GitgRepository *repository, Gi
gtk_label_set_markup(self->priv->subject, subject);
g_free(subject);
gtk_label_set_text(self->priv->date, format_date(revision));
gchar *date = gitg_utils_timestamp_to_str(gitg_revision_get_timestamp(revision));
gtk_label_set_text(self->priv->date, date);
g_free(date);
gchar *sha = gitg_revision_get_sha1(revision);
gtk_label_set_text(self->priv->sha, sha);

View file

@ -493,3 +493,15 @@ gitg_utils_new_builder(gchar const *filename)
g_free(path);
return b;
}
gchar *
gitg_utils_timestamp_to_str(guint64 timestamp)
{
time_t t = timestamp;
struct tm *tms = localtime(&t);
gchar buf[255];
strftime(buf, 254, "%c", tms);
return gitg_utils_convert_utf8(buf, -1);
}

View file

@ -60,7 +60,9 @@ void gitg_utils_menu_position_under_tree_view(GtkMenu *menu, gint *x, gint *y, g
gchar *gitg_utils_get_monospace_font_name();
void gitg_utils_set_monospace_font(GtkWidget *widget);
gchar *gitg_utils_timestamp_to_str(guint64 timestamp);
GtkBuilder *gitg_utils_new_builder(gchar const *filename);
#endif /* __GITG_UTILS_H__ */