From d24beddcdc9c4ec367dcaedb52e8e4dc17db636d Mon Sep 17 00:00:00 2001 From: DriverXX Date: Mon, 14 Mar 2016 22:00:59 +0100 Subject: Fix origin in props --- src/trg-torrent-props-dialog.c | 14 +++++++++----- src/util.c | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/trg-torrent-props-dialog.c b/src/trg-torrent-props-dialog.c index 322db0e..ae75146 100644 --- a/src/trg-torrent-props-dialog.c +++ b/src/trg-torrent-props-dialog.c @@ -333,11 +333,15 @@ static void info_page_update(TrgTorrentPropsDialog * dialog, gint64 dateCreated = torrent_get_date_created(t); gchar *dateStr = epoch_to_string(dateCreated); - if (!creator || strlen(creator) <= 0) - g_snprintf(buf, sizeof(buf), _("Created on %1$s"), dateStr); - else - g_snprintf(buf, sizeof(buf), _("Created by %1$s on %2$s"), - creator, dateStr); + if (creator && strlen(creator) > 0 && dateCreated > 0) + g_snprintf(buf, sizeof(buf), _("Created by %1$s on %2$s"), + creator, dateStr); + else if (dateCreated > 0) + g_snprintf(buf, sizeof(buf), _("Created on %1$s"), dateStr); + else if (creator && strlen(creator) > 0) + g_snprintf(buf, sizeof(buf), _("Created by %1$s"), creator); + else + g_strlcpy(buf, _("N/A"), sizeof(buf)); g_free(dateStr); gtk_label_set_text(GTK_LABEL(priv->origin_lb), buf); diff --git a/src/util.c b/src/util.c index 472af3b..de050aa 100644 --- a/src/util.c +++ b/src/util.c @@ -483,6 +483,8 @@ char *gtr_localtime2(char *buf, time_t time, size_t buflen) gchar *epoch_to_string(gint64 epoch) { + if(epoch == 0) + return g_strdup(_("N/A")); GDateTime *dt = g_date_time_new_from_unix_local(epoch); gchar *timestring = g_date_time_format(dt, "%F %H:%M:%S"); g_date_time_unref(dt); -- cgit v1.2.3