コード例 #1
0
/*****************************************************
**
**   EphemExpert   ---   writeKp
**
******************************************************/
void EphemExpert::writeKp( Writer *writer, const int &dasa )
{
	Lang lang;
	KPEvent *e;
	int d, m, y, lord, wd;
	vector<KPEvent>::iterator iter;
	TzUtil tzu;
	wxString s, thetime;
	vector<wxString> v;
	Table *table = 0;
	DasaExpert *expert = DasaExpertFactory::get()->getDasaExpert( dasa );
	if ( ! expert->hasKpFeatures() || dasa == 2 )
	{
		s.Printf( _( "K.P. events not supported for %s Dasa." ), expert->getName());
		writer->writeLine( s );
		return;
	}

	Formatter *formatter = Formatter::get();
	if ( ! chartprops->isVedic() )
	{
		writer->writeLine( _( "Not supported in western mode." ));
		return;
	}
	if ( ! ckp || mydasa != dasa ) calcKP( dasa );
	writeHeaderInfo( writer );

	//s.Printf( _( "%s Dasa" ), expert->getName());
	//writer->writeParagraph( s );

	lord = -1;
	int line = 1;
	int index = -1;
	for ( iter = kpevents.begin(); iter != kpevents.end(); iter++ )
	{
		e = (KPEvent*)(&(*iter));
		if ( e->dasaindex != index )
		{
			index = e->dasaindex;
			if ( table )
			{
				if ( expert->isRasiDasaExpert()) writer->writeHeader2( writer->getSignName( lord, TLARGE ));
				else writer->writeHeader2( writer->getObjectName( lord, TLARGE ));
				writer->writeTable( *table );
				delete table;
				table = 0;
			}
			table = new Table ( 5, 10 );
			table->setHeader( 0, _( "Day" ));
			table->setHeader( 1, _( "Time" ));
			table->setHeader( 2, _( "Lord" ));
			table->setHeader( 3, _( "Sublord" ));
			table->setHeader( 4, _( "Lunar Position" ));
			line = 1;
		}
		assert( table );
		formatter->getDateIntsFromJD( e->jd, d, m, y );
		wd = ((int)(e->jd + 1.5 )) % 7;
		assert( wd >= 0 && wd < 7 );
		s.Printf( wxT( "%02d %s" ), d, (const wxChar*)wxString( (const wxChar*)lang.getWeekdayName( wd )).Left(2) );
		table->setEntry( 0, line, s );

		TzFormattedDate fd = tzu.getDateFormatted( e->jd, isLocaltime );
		thetime = fd.timeFormatted;
		//if ( dstchange ) thetime << wxT( " " ) << fd.timezoneFormatted;
		table->setEntry( 1, line, thetime );
		//table->setEntry( 1, line, formatter->getTimeFormatted( getTimeFromJD( e->jd  + tz/24 )) );

		if ( expert->isRasiDasaExpert() )
		{
			table->setEntry( 2, line, writer->getSignName( e->lord, TLARGE ));
			table->setEntry( 3, line, writer->getSignName( e->sublord, TLARGE ));
		}
		else
		{
			table->setEntry( 2, line, writer->getObjectName( e->lord, TLARGE ));
			table->setEntry( 3, line, writer->getObjectName( e->sublord, TLARGE ));
		}
		table->setEntry( 4, line, writer->getPosFormatted( e->len, false ) );

		lord = e->lord;
		line++;
	}
	if ( table )
	{
		if ( expert->isRasiDasaExpert() )	writer->writeHeader2( writer->getSignName( e->lord, TLARGE ));
		else writer->writeHeader2( writer->getObjectName( e->lord, TLARGE ));
		writer->writeTable( *table );
		delete table;
		table = 0;
	}
}
コード例 #2
0
/*****************************************************
**
**   EphemExpert   ---   prepareMonth
**
******************************************************/
void EphemExpert::prepareMonth( const int &m, const int &y, const bool &isLocal )
{
	int dummy;
	double lastdst = 0;
	Formatter *formatter = Formatter::get();
	TzUtil tzu;
	TzInfo tzinfo;

	year = y;
	month = m;
	this->isLocaltime = isLocal;

	assert( month >= 0 && month <= 12 );
	assert( year >= -2000 && year <= 4000 );

	init();

	switch ( month )
	{
	case 0:
		formatter->getDateIntsFromJD( d->getJD(), dummy, month, year );
		break;
		break;
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12:
		nb_days = 31;
		break;
	case 2: // Feb
		nb_days = 28;
		if ( year % 4 == 0 )
		{
			nb_days = 29;
			if ( year % 100 == 0 ) nb_days = 28; // 1900, 1800 etc. have 28 days
			if ( year % 400 == 0 ) nb_days = 29; // BUT Feb 2000 has 29 days
		}
		break;
	default:
		nb_days = 30;
		break;
	}

	Formatter::get()->getDateIntsFromJD( JDate::getCurrentJD(), current_day, current_month, current_year );

	// set jds and week days
	for ( int i = 0; i <= nb_days; i++ ) // calc JDs for this month and year
	{
		d->setDate( i+1, month, year, 0 );
		jd[i] = d->getJD();
		weekday[i] = ((int)(jd[i] + 2 )) % 7;

		if ( isLocaltime )
		{
			tzinfo = tzu.calculateTzInfoForJD( jd[i] );
			double tzdelta = tzinfo.tzhours + tzinfo.dsthours;
			jd[i] -= tzdelta / 24.0;

			// test for dst change during month
			if ( i > 0 )
			{
				if ( lastdst != tzinfo.dsthours )
				{
					//printf( "DST change day %d last is %f current %f\n", i+1, lastdst, tzinfo.dsthours );
					dstchange = true;
				}
			}
			lastdst = tzinfo.dsthours;
			//printf( "Ephem: tzdelta %f day %d\n", tzdelta, i+1 );
		}
	}
}