Ignore:
Timestamp:
Oct 17, 2014, 5:12:00 AM (8 years ago)
Author:
livings124
Message:

Yosemite: use NSDateComponentsFormatter instead of custom time string code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Torrent.m

    r14290 r14341  
    2626#import "GroupsController.h"
    2727#import "FileListNode.h"
     28#import "NSApplicationAdditions.h"
    2829#import "NSStringAdditions.h"
    2930#import "TrackerNode.h"
     
    19811982        return NSLocalizedString(@"remaining time unknown", "Torrent -> eta string");
    19821983   
    1983     NSString * idleString = [NSString stringWithFormat: NSLocalizedString(@"%@ remaining", "Torrent -> eta string"),
    1984                                 [NSString timeString: eta showSeconds: YES maxFields: 2]];
    1985     if (fromIdle)
     1984    NSString * idleString;
     1985   
     1986    if ([NSApp isOnYosemiteOrBetter]) {
     1987        static NSDateComponentsFormatter *formatter;
     1988        static dispatch_once_t onceToken;
     1989        dispatch_once(&onceToken, ^{
     1990            formatter = [NSDateComponentsFormatter new];
     1991            formatter.unitsStyle = NSDateComponentsFormatterUnitsStyleShort;
     1992            formatter.maximumUnitCount = 2;
     1993            formatter.collapsesLargestUnit = YES;
     1994            formatter.includesTimeRemainingPhrase = YES;
     1995        });
     1996       
     1997        idleString = [formatter stringFromTimeInterval: eta];
     1998    }
     1999    else {
     2000        idleString = [NSString timeString: eta includesTimeRemainingPhrase: YES showSeconds: YES maxFields: 2];
     2001    }
     2002   
     2003    if (fromIdle) {
    19862004        idleString = [idleString stringByAppendingFormat: @" (%@)", NSLocalizedString(@"inactive", "Torrent -> eta string")];
     2005    }
    19872006   
    19882007    return idleString;
Note: See TracChangeset for help on using the changeset viewer.