Created
August 8, 2013 18:48
-
-
Save sck/6187509 to your computer and use it in GitHub Desktop.
c&p progress estimation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calculate time left if we're more than 10% done | |
NSString *timeString = nil; | |
float percentLeft = (float)([theCanvas eventCount]-[theCanvas currentPlaybackEvent])/(float)[theCanvas eventCount]; | |
NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; | |
if( percentLeft < 0.9f && now-_lastTimeWeEstimated > 5.0 ) { | |
_lastTimeWeEstimated = now; | |
NSTimeInterval timeLeft = (now-_exportStartTime)*(percentLeft/(1.0f-percentLeft)); | |
int hours = timeLeft/(60.0*60.0); | |
timeLeft -= (double)hours*60.0*60.0; | |
int mins = timeLeft/60.0; | |
timeLeft -= (double)mins*60.0; | |
int secs = timeLeft; | |
if( mins < 1 ) | |
timeString = NSLocalizedString(@"less than a minute",@"less than a minute"); | |
else | |
timeString = [NSString stringWithFormat:@"-%d:%02d:%02d",hours,mins,secs]; | |
//[_exportTimeText setStringValue:timeString]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment