diff options
author | Alan Fitton <ajf@eth0.org.uk> | 2012-03-01 22:01:25 +0000 |
---|---|---|
committer | Alan Fitton <ajf@eth0.org.uk> | 2012-03-01 22:01:25 +0000 |
commit | b913f788267327228cb27ef1a1de7aa556b789c3 (patch) | |
tree | 8b678e4b011f163ce2d0c5b3673dc4e5901ae90b /src/util.c | |
parent | a8fed4cb21f81bc1ce539d679da42d03a912469f (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.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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 |