cwTime.h/cpp : Added specToSeconds()
This commit is contained in:
parent
f5993f4aad
commit
2d646837a6
14
cwTime.cpp
14
cwTime.cpp
@ -274,6 +274,20 @@ void cw::time::secondsToSpec( spec_t& ts, unsigned sec )
|
|||||||
ts.tv_nsec = 0;
|
ts.tv_nsec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double cw::time::specToSeconds( const spec_t& t )
|
||||||
|
{
|
||||||
|
spec_t ts = t;
|
||||||
|
double sec = ts.tv_sec;
|
||||||
|
while( ts.tv_nsec >= 1e9 )
|
||||||
|
{
|
||||||
|
sec += 1.0;
|
||||||
|
ts.tv_nsec -= 1e9;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sec + ((double)ts.tv_nsec)/1e9;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void cw::time::millisecondsToSpec( spec_t& ts, unsigned ms )
|
void cw::time::millisecondsToSpec( spec_t& ts, unsigned ms )
|
||||||
{
|
{
|
||||||
unsigned sec = ms/1000;
|
unsigned sec = ms/1000;
|
||||||
|
2
cwTime.h
2
cwTime.h
@ -73,6 +73,8 @@ namespace cw
|
|||||||
rc_t futureMs( spec_t& ts, unsigned ms );
|
rc_t futureMs( spec_t& ts, unsigned ms );
|
||||||
|
|
||||||
void secondsToSpec( spec_t& ts, unsigned sec );
|
void secondsToSpec( spec_t& ts, unsigned sec );
|
||||||
|
double specToSeconds( const spec_t& ts );
|
||||||
|
|
||||||
void millisecondsToSpec( spec_t& ts, unsigned ms );
|
void millisecondsToSpec( spec_t& ts, unsigned ms );
|
||||||
void microsecondsToSpec( spec_t& ts, unsigned us );
|
void microsecondsToSpec( spec_t& ts, unsigned us );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user