[gitg] Fixed timestamp to date string conversion to be valid UTF-8 and
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Subject: [gitg] Fixed timestamp to date string conversion to be valid UTF-8 and
- Date: Sun, 5 Apr 2009 11:52:56 -0400 (EDT)
commit c5e8342da5f468a505f663a396a4c1ae247a3d67
Author: Jesse van den Kieboom <jesse icecrew nl>
Date: Sun Apr 5 17:51:57 2009 +0200
Fixed timestamp to date string conversion to be valid UTF-8 and
consistent (fixes bug #576685 and consequently debian bug #518705)
---
gitg/gitg-repository.c | 14 +-------------
gitg/gitg-revision-view.c | 18 +++---------------
gitg/gitg-utils.c | 12 ++++++++++++
gitg/gitg-utils.h | 4 +++-
4 files changed, 19 insertions(+), 29 deletions(-)
diff --git a/gitg/gitg-repository.c b/gitg/gitg-repository.c
index 4c9ef16..f7b9a64 100644
--- a/gitg/gitg-repository.c
+++ b/gitg/gitg-repository.c
@@ -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();
diff --git a/gitg/gitg-revision-view.c b/gitg/gitg-revision-view.c
index c41d495..84e35c5 100644
--- a/gitg/gitg-revision-view.c
+++ b/gitg/gitg-revision-view.c
@@ -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);
diff --git a/gitg/gitg-utils.c b/gitg/gitg-utils.c
index 557a032..27168ca 100644
--- a/gitg/gitg-utils.c
+++ b/gitg/gitg-utils.c
@@ -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);
+}
diff --git a/gitg/gitg-utils.h b/gitg/gitg-utils.h
index 6c0f345..3d08241 100644
--- a/gitg/gitg-utils.h
+++ b/gitg/gitg-utils.h
@@ -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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]