Print out string value for Julian
parent
78835261ae
commit
49477b4a4c
|
@ -5,6 +5,8 @@
|
|||
#include <ctime>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
|
@ -139,6 +141,21 @@ Julian Julian::operator-(const Timespan& b) const {
|
|||
return result;
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& stream, const Julian& julian) {
|
||||
std::stringstream out;
|
||||
struct Julian::DateTimeComponents datetime;
|
||||
julian.GetDateTime(&datetime);
|
||||
out << std::right << std::fixed << std::setprecision(3) << std::setfill('0');
|
||||
out << std::setw(4) << datetime.years << "-";
|
||||
out << std::setw(2) << datetime.months << "-";
|
||||
out << std::setw(2) << datetime.days << " ";
|
||||
out << std::setw(2) << datetime.hours << ":";
|
||||
out << std::setw(2) << datetime.minutes << ":";
|
||||
out << std::setw(6) << datetime.seconds;
|
||||
stream << out.str();
|
||||
return stream;
|
||||
}
|
||||
|
||||
/*
|
||||
* create julian date from year and day of year
|
||||
*/
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "Timespan.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
|
||||
class Julian {
|
||||
public:
|
||||
|
@ -14,6 +15,9 @@ public:
|
|||
Julian(int year, double day);
|
||||
Julian(int year, int mon, int day, int hour, int min, double sec);
|
||||
|
||||
~Julian() {
|
||||
};
|
||||
|
||||
/*
|
||||
* comparison operators
|
||||
*/
|
||||
|
@ -29,8 +33,7 @@ public:
|
|||
Julian operator+(const Timespan& b) const;
|
||||
Julian operator-(const Timespan& b) const;
|
||||
|
||||
~Julian() {
|
||||
};
|
||||
friend std::ostream & operator<<(std::ostream& stream, const Julian& julian);
|
||||
|
||||
struct DateTimeComponents {
|
||||
int years;
|
||||
|
|
|
@ -17,6 +17,7 @@ int main() {
|
|||
sgp4.FindPosition(&eci, now);
|
||||
CoordTopographic topo = obs.GetLookAngle(eci);
|
||||
CoordGeodetic geo = eci.ToGeodetic();
|
||||
std::cout << now << " ";
|
||||
std::cout << topo << " ";
|
||||
std::cout << geo << std::endl;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue