Code

utils: move format_duration_*() to time_format.c
[ncmpc.git] / src / utils.c
index 8f867ad36b87130d339b803bdde1ca2f4d366238..0c35c9e8e14089efb7483fe1c36374f0ad01221d 100644 (file)
@@ -18,7 +18,6 @@
  */
 
 #include "utils.h"
-#include "i18n.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -58,56 +57,3 @@ string_list_remove(GList *string_list, const gchar *str)
        }
        return list;
 }
-
-void
-format_duration_short(char *buffer, size_t length, unsigned duration)
-{
-       if (duration < 3600)
-               g_snprintf(buffer, length,
-                          "%i:%02i", duration / 60, duration % 60);
-       else
-               g_snprintf(buffer, length,
-                          "%i:%02i:%02i", duration / 3600,
-                          (duration % 3600) / 60, duration % 60);
-}
-
-void
-format_duration_long(char *p, size_t length, unsigned long duration)
-{
-       unsigned bytes_written = 0;
-
-       if (duration / 31536000 > 0) {
-               if (duration / 31536000 == 1)
-                       bytes_written = g_snprintf(p, length, "%d %s, ", 1, _("year"));
-               else
-                       bytes_written = g_snprintf(p, length, "%lu %s, ", duration / 31536000, _("years"));
-               duration %= 31536000;
-               length -= bytes_written;
-               p += bytes_written;
-       }
-       if (duration / 604800 > 0) {
-               if (duration / 604800 == 1)
-                       bytes_written = g_snprintf(p, length, "%d %s, ",
-                                                  1, _("week"));
-               else
-                       bytes_written = g_snprintf(p, length, "%lu %s, ",
-                                                  duration / 604800, _("weeks"));
-               duration %= 604800;
-               length -= bytes_written;
-               p += bytes_written;
-       }
-       if (duration / 86400 > 0) {
-               if (duration / 86400 == 1)
-                       bytes_written = g_snprintf(p, length, "%d %s, ",
-                                                  1, _("day"));
-               else
-                       bytes_written = g_snprintf(p, length, "%lu %s, ",
-                                                  duration / 86400, _("days"));
-               duration %= 86400;
-               length -= bytes_written;
-               p += bytes_written;
-       }
-
-       g_snprintf(p, length, "%02lu:%02lu:%02lu", duration / 3600,
-                  duration % 3600 / 60, duration % 3600 % 60);
-}