Changeset 525 for trunk/gtk/util.c


Ignore:
Timestamp:
Jul 4, 2006, 10:31:14 PM (16 years ago)
Author:
joshe
Message:

Move the ETA cap of 99:59:59 from libtransmission to the MacOS X GUI.
Display the ETA better in the GTK GUI.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/util.c

    r320 r525  
    8585}
    8686
     87#define SECONDS(s)              ((s) % 60)
     88#define MINUTES(s)              ((s) / 60 % 60)
     89#define HOURS(s)                ((s) / 60 / 60 % 24)
     90#define DAYS(s)                 ((s) / 60 / 60 / 24 % 7)
     91#define WEEKS(s)                ((s) / 60 / 60 / 24 / 7)
     92
     93char *
     94readabletime(int secs) {
     95  if(60 > secs)
     96    return g_strdup_printf(_("%i %s"),
     97      SECONDS(secs), ngettext("second", "seconds", SECONDS(secs)));
     98  else if(60 * 60 > secs)
     99    return g_strdup_printf(_("%i %s %i %s"),
     100      MINUTES(secs), ngettext("minute", "minutes", MINUTES(secs)),
     101      SECONDS(secs), ngettext("second", "seconds", SECONDS(secs)));
     102  else if(60 * 60 * 24 > secs)
     103    return g_strdup_printf(_("%i %s %i %s"),
     104      HOURS(secs),   ngettext("hour", "hours", HOURS(secs)),
     105      MINUTES(secs), ngettext("minute", "minutes", MINUTES(secs)));
     106  else if(60 * 60 * 24 * 7 > secs)
     107    return g_strdup_printf(_("%i %s %i %s"),
     108      DAYS(secs),    ngettext("day", "days", DAYS(secs)),
     109      HOURS(secs),   ngettext("hour", "hours", HOURS(secs)));
     110  else
     111    return g_strdup_printf(_("%i %s %i %s"),
     112      WEEKS(secs),   ngettext("week", "weeks", WEEKS(secs)),
     113      DAYS(secs),    ngettext("hour", "hours", DAYS(secs)));
     114}
     115
    87116char *
    88117ratiostr(guint64 down, guint64 up) {
Note: See TracChangeset for help on using the changeset viewer.