Skip to content

Commit

Permalink
Added debugging output to times
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicDirkx committed Oct 31, 2023
1 parent 445bd01 commit 3d0ef05
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tudatpy/kernel/expose_astro/expose_time_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,23 @@ tba::DateTime timePointToDateTime(const std::chrono::system_clock::time_point da
{
std::time_t tt = std::chrono::system_clock::to_time_t(datetime);
std::tm local_tm = *localtime(&tt);
std::cout<<"Input time decomposed "
<<local_tm.tm_year + 1900<<" "<<local_tm.tm_mon + 1<<" "<<local_tm.tm_mday<<" "
<<local_tm.tm_hour <<" "<<local_tm.tm_min + 1<<" "<<local_tm.tm_sec<<std::endl;

using namespace std::chrono;
microseconds timeInMicroSeconds = duration_cast<microseconds>(datetime.time_since_epoch());
microseconds timeInSeconds = duration_cast<seconds>(datetime.time_since_epoch());


long long fractional_seconds = timeInMicroSeconds.count() % 1000000LL;
std::cout<<"Microseconds "<<timeInMicroSeconds.count()<<" "<<fractional_seconds<<std::endl;
std::cout<<"Seconds "<<timeInSeconds.count()<<std::endl;

return tba::DateTime( local_tm.tm_year + 1900, local_tm.tm_mon + 1, local_tm.tm_mday,
local_tm.tm_hour, local_tm.tm_min, static_cast< long double >( local_tm.tm_sec ) +
static_cast< long double >( fractional_seconds ) /
tudat::mathematical_constants::getFloatingInteger< long double >( 1000000 ) );
tudat::mathematical_constants::getFloatingInteger< long double >( 1000000LL ) );
}

// Convert from Gregorian date to time_point (Python datetime). Only year/month/day, no time.
Expand Down

0 comments on commit 3d0ef05

Please sign in to comment.