Ignore:
Timestamp:
Nov 19, 2007, 8:00:18 PM (15 years ago)
Author:
livings124
Message:

move code to generate time string to its own method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/StatsWindowController.m

    r3890 r3891  
    3131
    3232- (void) updateStats;
     33- (NSString *) timeString: (uint64_t) seconds;
    3334
    3435@end
     
    8283    [fRatioField setStringValue: [NSString stringForRatio: stats.ratio]];
    8384   
     85    [fTimeField setStringValue: [self timeString: stats.secondsActive]];
     86   
     87    [fNumOpenedField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d Times", "stats window -> times opened"),
     88                                        stats.sessionCount]];
     89}
     90
     91- (NSString *) timeString: (uint64_t) seconds
     92{
    8493    NSMutableArray * timeArray = [NSMutableArray arrayWithCapacity: 4];
    85     uint64_t seconds = stats.secondsActive;
    86     if (stats.secondsActive >= 86400) //24 * 60 * 60
     94   
     95    if (seconds >= 86400) //24 * 60 * 60
    8796    {
    8897        int days = seconds / 86400;
     
    94103        seconds %= 86400;
    95104    }
    96     if (stats.secondsActive >= 3600) //60 * 60
     105    if (seconds >= 3600) //60 * 60
    97106    {
    98107        [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d hours", "stats window -> running time"),
     
    100109        seconds %= 3600;
    101110    }
    102     if (stats.secondsActive >= 60)
     111    if (seconds >= 60)
    103112    {
    104113        [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d min", "stats window -> running time"), seconds / 60]];
     
    106115    }
    107116    [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d sec", "stats window -> running time"), seconds]];
    108     [fTimeField setStringValue: [timeArray componentsJoinedByString: @" "]];
    109117   
    110     [fNumOpenedField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d Times", "stats window -> times opened"),
    111                                         stats.sessionCount]];
     118    return [timeArray componentsJoinedByString: @" "];
    112119}
    113120
Note: See TracChangeset for help on using the changeset viewer.