aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/lltimer.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llcommon/lltimer.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llcommon/lltimer.cpp')
-rw-r--r--linden/indra/llcommon/lltimer.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/linden/indra/llcommon/lltimer.cpp b/linden/indra/llcommon/lltimer.cpp
index 25d9897..967570d 100644
--- a/linden/indra/llcommon/lltimer.cpp
+++ b/linden/indra/llcommon/lltimer.cpp
@@ -429,10 +429,9 @@ BOOL LLTimer::knownBadTimer()
429// 429//
430/////////////////////////////////////////////////////////////////////////////// 430///////////////////////////////////////////////////////////////////////////////
431 431
432U32 time_corrected() 432time_t time_corrected()
433{ 433{
434 U32 corrected_time = (U32)time(NULL) + gUTCOffset; 434 return time(NULL) + gUTCOffset;
435 return corrected_time;
436} 435}
437 436
438 437
@@ -452,27 +451,25 @@ BOOL is_daylight_savings()
452} 451}
453 452
454 453
455struct tm* utc_to_pacific_time(S32 utc_time, BOOL pacific_daylight_time) 454struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_daylight_time)
456{ 455{
457 time_t unix_time = (time_t)utc_time;
458
459 S32 pacific_offset_hours; 456 S32 pacific_offset_hours;
460 if (pacific_daylight_time) 457 if (pacific_daylight_time)
461 { 458 {
462 pacific_offset_hours = -7; 459 pacific_offset_hours = 7;
463 } 460 }
464 else 461 else
465 { 462 {
466 pacific_offset_hours = -8; 463 pacific_offset_hours = 8;
467 } 464 }
468 465
469 // We subtract off the PST/PDT offset _before_ getting 466 // We subtract off the PST/PDT offset _before_ getting
470 // "UTC" time, because this will handle wrapping around 467 // "UTC" time, because this will handle wrapping around
471 // for 5 AM UTC -> 10 PM PDT of the previous day. 468 // for 5 AM UTC -> 10 PM PDT of the previous day.
472 unix_time += pacific_offset_hours * MIN_PER_HOUR * SEC_PER_MIN; 469 utc_time -= pacific_offset_hours * MIN_PER_HOUR * SEC_PER_MIN;
473 470
474 // Internal buffer to PST/PDT (see above) 471 // Internal buffer to PST/PDT (see above)
475 struct tm* internal_time = gmtime(&unix_time); 472 struct tm* internal_time = gmtime(&utc_time);
476 473
477 /* 474 /*
478 // Don't do this, this won't correctly tell you if daylight savings is active in CA or not. 475 // Don't do this, this won't correctly tell you if daylight savings is active in CA or not.
@@ -486,7 +483,7 @@ struct tm* utc_to_pacific_time(S32 utc_time, BOOL pacific_daylight_time)
486} 483}
487 484
488 485
489void microsecondsToTimecodeString(U64 current_time, char *tcstring) 486void microsecondsToTimecodeString(U64 current_time, std::string& tcstring)
490{ 487{
491 U64 hours; 488 U64 hours;
492 U64 minutes; 489 U64 minutes;
@@ -504,11 +501,11 @@ void microsecondsToTimecodeString(U64 current_time, char *tcstring)
504 subframes = current_time / (U64)42; 501 subframes = current_time / (U64)42;
505 subframes %= 100; 502 subframes %= 100;
506 503
507 sprintf(tcstring,"%3.3d:%2.2d:%2.2d:%2.2d.%2.2d",(int)hours,(int)minutes,(int)seconds,(int)frames,(int)subframes); /* Flawfinder: ignore */ 504 tcstring = llformat("%3.3d:%2.2d:%2.2d:%2.2d.%2.2d",(int)hours,(int)minutes,(int)seconds,(int)frames,(int)subframes);
508} 505}
509 506
510 507
511void secondsToTimecodeString(F32 current_time, char *tcstring) 508void secondsToTimecodeString(F32 current_time, std::string& tcstring)
512{ 509{
513 microsecondsToTimecodeString((U64)((F64)(SEC_TO_MICROSEC*current_time)), tcstring); 510 microsecondsToTimecodeString((U64)((F64)(SEC_TO_MICROSEC*current_time)), tcstring);
514} 511}
@@ -541,7 +538,7 @@ void LLEventTimer::updateClass()
541 { 538 {
542 LLEventTimer* timer = *iter++; 539 LLEventTimer* timer = *iter++;
543 F32 et = timer->mEventTimer.getElapsedTimeF32(); 540 F32 et = timer->mEventTimer.getElapsedTimeF32();
544 if (et > timer->mPeriod) { 541 if (timer->mEventTimer.getStarted() && et > timer->mPeriod) {
545 timer->mEventTimer.reset(); 542 timer->mEventTimer.reset();
546 if ( timer->tick() ) 543 if ( timer->tick() )
547 { 544 {