comparison base/RealTime.cpp @ 1031:344c9ea90181

Add option to toggle H:M:S time display (when off, just show seconds even when more than 60)
author Chris Cannam
date Wed, 18 Feb 2015 12:08:17 +0000
parents ee9f4477f65b
children cc27f35aa75c
comparison
equal deleted inserted replaced
1030:920699b6989d 1031:344c9ea90181
272 if (fps != 0) return toFrameText(fps); 272 if (fps != 0) return toFrameText(fps);
273 } 273 }
274 274
275 std::stringstream out; 275 std::stringstream out;
276 276
277 if (sec >= 3600) { 277 if (p->getShowHMS()) {
278 out << (sec / 3600) << ":"; 278
279 } 279 if (sec >= 3600) {
280 280 out << (sec / 3600) << ":";
281 if (sec >= 60) { 281 }
282 out << (sec % 3600) / 60 << ":"; 282
283 } 283 if (sec >= 60) {
284 284 out << (sec % 3600) / 60 << ":";
285 if (sec >= 10) { 285 }
286 out << ((sec % 60) / 10); 286
287 } 287 if (sec >= 10) {
288 288 out << ((sec % 60) / 10);
289 out << (sec % 10); 289 }
290
291 out << (sec % 10);
292
293 } else {
294 out << sec;
295 }
290 296
291 int ms = msec(); 297 int ms = msec();
292 298
293 if (ms != 0) { 299 if (ms != 0) {
294 out << "."; 300 out << ".";
317 std::string 323 std::string
318 RealTime::toFrameText(int fps) const 324 RealTime::toFrameText(int fps) const
319 { 325 {
320 if (*this < RealTime::zeroTime) return "-" + (-*this).toFrameText(fps); 326 if (*this < RealTime::zeroTime) return "-" + (-*this).toFrameText(fps);
321 327
328 Preferences *p = Preferences::getInstance();
329
322 std::stringstream out; 330 std::stringstream out;
323 331
324 if (sec >= 3600) { 332 if (p->getShowHMS()) {
325 out << (sec / 3600) << ":"; 333
326 } 334 if (sec >= 3600) {
327 335 out << (sec / 3600) << ":";
328 if (sec >= 60) { 336 }
329 out << (sec % 3600) / 60 << ":"; 337
330 } 338 if (sec >= 60) {
331 339 out << (sec % 3600) / 60 << ":";
332 if (sec >= 10) { 340 }
333 out << ((sec % 60) / 10); 341
334 } 342 if (sec >= 10) {
335 343 out << ((sec % 60) / 10);
336 out << (sec % 10); 344 }
345
346 out << (sec % 10);
347
348 } else {
349 out << sec;
350 }
337 351
338 int f = nsec / (ONE_BILLION / fps); 352 int f = nsec / (ONE_BILLION / fps);
339 353
340 int div = 1; 354 int div = 1;
341 int n = fps - 1; 355 int n = fps - 1;