Changeset 13443


Ignore:
Timestamp:
Aug 18, 2012, 4:33:28 PM (9 years ago)
Author:
jordan
Message:

(trunk, daemon) #4657 "transmission-remote: display times (e.g. Seeding Time) (optionally) in seconds" -- added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/remote.c

    r13266 r13443  
    9090tr_strltime( char * buf, int seconds, size_t buflen )
    9191{
    92     int  days, hours, minutes;
    93     char d[128], h[128], m[128], s[128];
     92    int  days, hours, minutes, total_seconds;
     93    char b[128], d[128], h[128], m[128], s[128], t[128];
    9494
    9595    if( seconds < 0 )
    9696        seconds = 0;
    9797
     98    total_seconds = seconds;
    9899    days = seconds / 86400;
    99100    hours = ( seconds % 86400 ) / 3600;
     
    104105    tr_snprintf( h, sizeof( h ), "%d %s", hours, hours==1?"hour":"hours" );
    105106    tr_snprintf( m, sizeof( m ), "%d %s", minutes, minutes==1?"minute":"minutes" );
    106     tr_snprintf( s, sizeof( s ), "%d %s", seconds, seconds==1?"seconds":"seconds" );
     107    tr_snprintf( s, sizeof( s ), "%d %s", seconds, seconds==1?"second":"seconds" );
     108    tr_snprintf( t, sizeof( t ), "%d %s", total_seconds, total_seconds==1?"seconds":"seconds" );
    107109
    108110    if( days )
    109111    {
    110112        if( days >= 4 || !hours )
    111             tr_strlcpy( buf, d, buflen );
     113            tr_strlcpy( b, d, sizeof( b ) );
    112114        else
    113             tr_snprintf( buf, buflen, "%s, %s", d, h );
     115            tr_snprintf( b, sizeof( b ), "%s, %s", d, h );
    114116    }
    115117    else if( hours )
    116118    {
    117119        if( hours >= 4 || !minutes )
    118             tr_strlcpy( buf, h, buflen );
     120            tr_strlcpy( b, h, sizeof( b ) );
    119121        else
    120             tr_snprintf( buf, buflen, "%s, %s", h, m );
     122            tr_snprintf( b, sizeof( b ), "%s, %s", h, m );
    121123    }
    122124    else if( minutes )
    123125    {
    124126        if( minutes >= 4 || !seconds )
    125             tr_strlcpy( buf, m, buflen );
     127            tr_strlcpy( b, m, sizeof( b ) );
    126128        else
    127             tr_snprintf( buf, buflen, "%s, %s", m, s );
    128     }
    129     else tr_strlcpy( buf, s, buflen );
    130 
     129            tr_snprintf( b, sizeof( b ), "%s, %s", m, s );
     130    }
     131    else tr_strlcpy( b, s, sizeof( b ) );
     132
     133    tr_snprintf( buf, buflen, "%s (%s)", b, t );
    131134    return buf;
    132135}
Note: See TracChangeset for help on using the changeset viewer.