[Kstars-devel] kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Thu May 13 09:21:58 CEST 2004


CVS commit by harris: 

Two SimClock fixes:

manualTick(): SimClock stores the timescale as a double, 
representing the size of the timestep in seconds.  
manualTick() used to advance the clock by calling 
setUTC( UTC().addSecs( int( Scale ) ) );

This did not work if the Scale was larger than the range 
of integers.  We now divide Scale by 86400. to get the 
integer number of days, and then call addDays(ndays) and 
addSecs( int(Scale - ndays*86400) ) to advance the clock 
correctly.

setUTC(): Do not set the time if the requested ExtDateTime 
is invalid.

CCMAIL: kstars-devel at kde.org


  M +20 -13    simclock.cpp   1.17


--- kdeedu/kstars/kstars/simclock.cpp  #1.16:1.17
@@ -106,6 +106,10 @@ void SimClock::setManualMode( bool on ) 
 void SimClock::manualTick( bool force ) {
         if ( force || (ManualMode && ManualActive) ) {
-                setUTC( UTC().addSecs( int( Scale ) ) );
-                julian += Scale / ( 24.*3600. );
+                int dDays = int( Scale / 86400. );
+                int dSecs = int( Scale - dDays*86400. );
+                ExtDateTime newUT( UTC().addDays( dDays ) );
+                newUT = newUT.addSecs( dSecs );
+                setUTC( newUT );
+                julian += Scale/86400.;
         } else if ( ! ManualMode ) tick();
 }
@@ -165,6 +169,6 @@ void SimClock::start() {
 
 void SimClock::setUTC(const ExtDateTime &newtime) {
+        if ( newtime.isValid() ) {
         utc = newtime;
-        utcvalid = true;
         julian = KSUtils::UTtoJD(utc);
         if (tmr.isActive()) {
@@ -173,8 +177,11 @@ void SimClock::setUTC(const ExtDateTime 
                 lastelapsed = 0;
         }
+                
         kdDebug() << i18n( "Setting clock UTC = " ) << utc.toString() <<
                 i18n( " julian day = " ) << QString("%1").arg( julian, 10, 'f', 2) << endl;
         emit timeChanged();
-
+        } else {
+                kdDebug() << i18n( "Cannot set SimClock:  Invalid Date/Time." ) << endl;
+        }
 }
 




More information about the Kstars-devel mailing list