Skip to content

Commit

Permalink
fix: fix linking error on mac (#3270)
Browse files Browse the repository at this point in the history
* Move the definition of fromDuration from Units.cpp to Units.hpp
  • Loading branch information
rrsettgast authored Aug 7, 2024
1 parent 6972791 commit c914283
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
19 changes: 0 additions & 19 deletions src/coreComponents/common/Units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,6 @@ std::ostream & operator<<( std::ostream & os, TimeFormatInfo const & info )
return os;
}


template< typename DURATION >
TimeFormatInfo TimeFormatInfo::fromDuration( DURATION const value )
{
using namespace std::chrono;

auto const totalYears = duration_cast< units::Years >( value );
auto const daysOut = duration_cast< units::Days >( value - totalYears );
auto const hoursOut = duration_cast< hours >( value - totalYears - daysOut );
auto const minutesOut = duration_cast< minutes >( value - totalYears - daysOut - hoursOut );
auto const secondsOut = duration_cast< seconds >( value - totalYears - daysOut - hoursOut - minutesOut );

return TimeFormatInfo( duration< double >( value ).count(), int( totalYears.count() ),
int( daysOut.count() ), int( hoursOut.count() ),
int( minutesOut.count() ), int( secondsOut.count() ) );
}
// available specializations
template TimeFormatInfo TimeFormatInfo::fromDuration< SystemClock::duration >( SystemClock::duration duration );

TimeFormatInfo TimeFormatInfo::fromSeconds( double const seconds )
{
double remainingSeconds = seconds < 0.0 ? -seconds : seconds;
Expand Down
15 changes: 15 additions & 0 deletions src/coreComponents/common/Units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,21 @@ struct TimeFormatInfo
string toSecondsString() const;
};

template< typename DURATION >
TimeFormatInfo TimeFormatInfo::fromDuration( DURATION const value )
{
using namespace std::chrono;

auto const totalYears = duration_cast< units::Years >( value );
auto const daysOut = duration_cast< units::Days >( value - totalYears );
auto const hoursOut = duration_cast< hours >( value - totalYears - daysOut );
auto const minutesOut = duration_cast< minutes >( value - totalYears - daysOut - hoursOut );
auto const secondsOut = duration_cast< seconds >( value - totalYears - daysOut - hoursOut - minutesOut );

return TimeFormatInfo( duration< double >( value ).count(), int( totalYears.count() ),
int( daysOut.count() ), int( hoursOut.count() ),
int( minutesOut.count() ), int( secondsOut.count() ) );
}

} // end namespace units

Expand Down

0 comments on commit c914283

Please sign in to comment.