summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2012-03-01 22:01:25 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2012-03-01 22:01:25 +0000
commitb913f788267327228cb27ef1a1de7aa556b789c3 (patch)
tree8b678e4b011f163ce2d0c5b3673dc4e5901ae90b /src/util.c
parenta8fed4cb21f81bc1ce539d679da42d03a912469f (diff)
fix memory leak and improvement on the url comment patch, and add a completed at item to the general panel.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 1a6f2e8..a67a5db 100644
--- a/src/util.c
+++ b/src/util.c
@@ -490,6 +490,22 @@ int tr_snprintf(char *buf, size_t buflen, const char *fmt, ...)
return len;
}
+gchar *epoch_to_string(gint64 epoch)
+{
+#if GLIB_CHECK_VERSION(2, 26, 00)
+ 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);
+ return timestring;
+#else
+ char buf[64];
+ time_t time_val = epoch;
+ struct tm *ts = localtime(&time_val);
+ int wrote = strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ts);
+ return g_strndup(buf, wrote);
+#endif
+}
+
size_t tr_strlcpy(char *dst, const void *src, size_t siz)
{
#ifdef HAVE_STRLCPY