Changeset 5118


Ignore:
Timestamp:
Feb 26, 2008, 12:28:22 AM (14 years ago)
Author:
livings124
Message:

format time string using unsigned values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/NSStringAdditions.m

    r5117 r5118  
    110110+ (NSString *) timeString: (NSUInteger) seconds showSeconds: (BOOL) showSeconds maxDigits: (NSUInteger) max
    111111{
    112     NSLog(@"seconds: %u max digits: %u", seconds, max);
    113112    NSMutableArray * timeArray = [NSMutableArray arrayWithCapacity: MIN(max, 4)];
    114     uint64_t remaining = seconds;
     113    NSUInteger remaining = seconds;
    115114   
    116115    if (max > 0 && seconds >= 86400) //24 * 60 * 60
     
    120119            [timeArray addObject: NSLocalizedString(@"1 day", "time string")];
    121120        else
    122             [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d days", "time string"), days]];
     121            [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%u days", "time string"), days]];
    123122        remaining %= 86400;
    124123        max--;
     
    126125    if (max > 0 && seconds >= 3600) //60 * 60
    127126    {
    128         [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d hr", "time string"), remaining / 3600]];
     127        [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%u hr", "time string"), remaining / 3600]];
    129128        remaining %= 3600;
    130129        max--;
     
    132131    if (max > 0 && (!showSeconds || seconds >= 60))
    133132    {
    134         [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d min", "time string"), remaining / 60]];
     133        [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%u min", "time string"), remaining / 60]];
    135134        remaining %= 60;
    136135        max--;
    137136    }
    138137    if (max > 0 && showSeconds)
    139         [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d sec", "time string"), remaining]];
     138        [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%u sec", "time string"), remaining]];
    140139   
    141140    return [timeArray componentsJoinedByString: @" "];
Note: See TracChangeset for help on using the changeset viewer.