[Kstars-devel] kdeedu/kstars/kstars
Jason Harris
kstars at 30doradus.org
Sun Jun 6 04:43:18 CEST 2004
CVS commit by harris:
One more from the feature plan: adding "--date" argument to image-dump mode.
Please update libkdeedu/extdate before testing this function. The date can be
in several different formats:
2001-07-21 19:30:00
Jul 21 2001 19:30:00
21 Jul 2001 19:30:00
(each format is acceptable without the time as well; the time will default to
midnight)
CCMAIL: kstars-devel at kde.org
M +8 -0 kstarsdatetime.cpp 1.2
M +1 -0 kstarsdatetime.h 1.2
M +32 -3 main.cpp 1.37
--- kdeedu/kstars/kstars/kstarsdatetime.cpp #1.1:1.2
@@ -34,4 +34,12 @@ KStarsDateTime::KStarsDateTime( const KS
}
+KStarsDateTime::KStarsDateTime( const ExtDateTime &edt ) : ExtDateTime( edt ) {
+ //don't call setDJD() because we don't need to compute the time; just set DJD directly
+ QTime _t = edt.time();
+ ExtDate _d = edt.date();
+ long double jdFrac = ( _t.hour()-12 + ( _t.minute() + ( _t.second() + _t.msec()/1000.)/60.)/60.)/24.;
+ DJD = (long double)( _d.jd() ) + jdFrac;
+}
+
KStarsDateTime::KStarsDateTime( const ExtDate &_d, const QTime &_t ) : ExtDateTime( _d, _t ) {
//don't call setDJD() because we don't need to compute the time; just set DJD directly
--- kdeedu/kstars/kstars/kstarsdatetime.h #1.1:1.2
@@ -40,4 +40,5 @@ public:
KStarsDateTime( long int jd );
KStarsDateTime( const KStarsDateTime &kdt );
+ KStarsDateTime( const ExtDateTime &kdt );
KStarsDateTime( const ExtDate &_d, const QTime &_t );
KStarsDateTime( double djd );
--- kdeedu/kstars/kstars/main.cpp #1.36:1.37
@@ -44,4 +44,5 @@ static KCmdLineOptions options[] =
{ "width ", I18N_NOOP( "width of sky image" ), "640" },
{ "height ", I18N_NOOP( "height of sky image" ), "480" },
+ { "date ", I18N_NOOP( "date and time" ), "" },
{ "filename ", I18N_NOOP( "filename for sky image" ), "kstars.png" },
KCmdLineLastOption
@@ -103,6 +104,34 @@ int main(int argc, char *argv[])
dat->colorScheme()->loadFromConfig( kapp->config() );
- //reset clock now that we have a location:
- dat->clock()->setUTC( KStarsDateTime::currentDateTime() );
+ //set clock now that we have a location:
+ //Check to see if user provided a date/time string. If not, use current CPU time
+ QString datestring = args->getOption( "date" );
+ KStarsDateTime kdt;
+ if ( ! datestring.isEmpty() ) {
+ if ( datestring.contains( "-" ) ) { //assume ISODate format
+ if ( datestring.contains( ":" ) ) { //also includes time
+ kdt = KStarsDateTime::fromString( datestring, Qt::ISODate );
+ } else { //string probably contains date only
+ kdt.setDate( ExtDate::fromString( datestring, Qt::ISODate ) );
+ kdt.setTime( QTime( 0, 0, 0 ) );
+ }
+ } else { //assume Text format for date string
+ kdt = KStarsDateTime::fromString( datestring, Qt::TextDate );
+ }
+
+ if ( ! kdt.isValid() ) {
+ kdWarning() << i18n( "Could not parse Date/Time string: " ) << datestring << endl;
+ kdWarning() << i18n( "Valid date formats: " ) << endl;
+ kdWarning() << " 1950-02-25 ; 1950-02-25 05:30:00" << endl;
+ kdWarning() << " Feb 25 1950 ; Feb 25 1950 05:30:00" << endl;
+ kdWarning() << " 25 Feb 1950 ; 25 Feb 1950 05:30:00" << endl;
+ kdWarning() << i18n( "Using CPU date/time instead." ) << endl;
+
+ kdt = KStarsDateTime::currentDateTime();
+ }
+ } else {
+ kdt = KStarsDateTime::currentDateTime();
+ }
+ dat->clock()->setUTC( kdt );
KSNumbers num( dat->ut().djd() );
More information about the Kstars-devel
mailing list