Example #1
0
wxString pgsTimeGen::random()
{
	wxTimeSpan time_span(0, 0, m_randomizer->random_long(), 0);
	wxDateTime aux_min(m_min);
	aux_min.Add(time_span);
	wxASSERT(aux_min.IsLaterThan(m_min) || aux_min.IsEqualTo(m_min));
	wxASSERT(aux_min.IsEarlierThan(m_max) || aux_min.IsEqualTo(m_max));
	return aux_min.FormatISOTime();
}
wxString pgsDateTimeGen::random()
{
	// Get a random number representing seconds
	MAPM result = pgsMapm::pgs_str_mapm(m_randomizer->random()), quot, rem;
	
	// Use hours and seconds for avoiding overflows of seconds
	result.integer_div_rem(3600, quot, rem);
	long hours, seconds;
	pgsMapm::pgs_mapm_str(quot, true).ToLong(&hours);
	pgsMapm::pgs_mapm_str(rem, true).ToLong(&seconds);
	wxTimeSpan time_span(hours, 0, seconds, 0);
	
	// Add the TimeSpan to the MinDate
	wxDateTime aux_min(m_min);
	aux_min.Add(time_span);
	
	// Post conditions
	wxASSERT(aux_min.IsLaterThan(m_min) || aux_min.IsEqualTo(m_min));
	wxASSERT(aux_min.IsEarlierThan(m_max) || aux_min.IsEqualTo(m_max));
	
	return aux_min.Format(wxT("%Y-%m-%d %H:%M:%S"));
}
Example #3
0
void win32_windowed_app::handle_trace(const char* file_name, int line_number, bool add_newline, const char* message) {
    UNUSED_PARAMETER(file_name);
    UNUSED_PARAMETER(line_number);
    print(build_string("[{}] {}{}", time_span().build_from_seconds(get_real_time_in_seconds()).to_hours_minutes_seconds_string(), message, add_newline ? "\n" : "").c_str());
}
time_span  time_stamp::operator-( const time_stamp& rhs ) const {
	return time_span( _tick - rhs._tick );
}
Example #5
0
time_span time_span::from_hours( const int32_t v ) {
    return time_span( v * static_cast<int64_t>(tick::HOUR_TO_MICRO_SECONDS ));
}
Example #6
0
time_span time_span::from_days( const int32_t v ) {
    return time_span( v * static_cast<int64_t>(tick::DAY_TO_MICRO_SECONDS ));
}
Example #7
0
time_span time_span::from_milli_seconds( const int64_t v ) {
    return time_span( v * static_cast<int64_t>(tick::MILLI_SECOND_TO_MICRO_SECONDS ));
}
Example #8
0
time_span time_span::from_minutes( const int32_t v ) {
    return time_span( v * static_cast<int64_t>(tick::MINUTE_TO_MICRO_SECONDS ));
}
Example #9
0
namespace tdk {

const int64_t time_span::INFINITE_DELTA = 0x7FFFFFFFFFFFFFFF; //MAXINT64;
const time_span time_span::INFINITE_TIME = time_span( INFINITE_DELTA );

time_span::time_span( void ) : _delta(0) {

}

time_span::~time_span( void ) {

}

time_span::time_span( const time_span& rhs ) : _delta( rhs._delta ) {

}

time_span::time_span( const uint32_t hours 
					 , const uint32_t minutes 
					 , const uint32_t seconds ) 
    : _delta( hours ) {
    _delta *= static_cast<int64_t>(tick::HOUR_TO_MINUTES);
    _delta += minutes;
    _delta *= static_cast<int64_t>(tick::MINUTE_TO_SECONDS);
    _delta += seconds;
    _delta *= static_cast<int64_t>(tick::SECOND_TO_MICRO_SECONDS);
}

time_span::time_span( const uint32_t days 
					 , const uint32_t hours 
					 , const uint32_t minutes 
					 , const uint32_t seconds ) 
: _delta( days ) {
    _delta *= static_cast<const int64_t>(tick::DAY_TO_HOURS);
    _delta += hours;
    _delta *= static_cast<const int64_t>(tick::HOUR_TO_MINUTES);
    _delta += minutes;
    _delta *= static_cast<const int64_t>(tick::MINUTE_TO_SECONDS);
    _delta += seconds;
    _delta *= static_cast<const int64_t>(tick::SECOND_TO_MICRO_SECONDS);    
}

time_span::time_span( const uint32_t days 
					 , const uint32_t hours 
					 , const uint32_t minutes 
					 , const uint32_t seconds 
					 , const uint32_t milliseconds )
: _delta( days ) {
    _delta *= static_cast<int64_t>(tick::DAY_TO_HOURS);
    _delta += hours;
    _delta *= static_cast<int64_t>(tick::HOUR_TO_MINUTES);
    _delta += minutes;
    _delta *= static_cast<int64_t>(tick::MINUTE_TO_SECONDS);
    _delta += seconds;
    _delta *= static_cast<int64_t>(tick::SECOND_TO_MILLI_SECONDS);
    _delta += milliseconds;
    _delta *= static_cast<int64_t>(tick::MILLI_SECOND_TO_MICRO_SECONDS);
}


time_span& time_span::operator=( const time_span& rhs ) {
    _delta = rhs._delta;
    return *this;
}

time_span::time_span( const int64_t microSec ) : _delta(microSec) {

}

int64_t time_span::delta( void ) const {
    return _delta;
}

time_span time_span::from_micro_seconds( const int64_t v ) {
    return time_span( v );
}

time_span time_span::from_milli_seconds( const int64_t v ) {
    return time_span( v * static_cast<int64_t>(tick::MILLI_SECOND_TO_MICRO_SECONDS ));
}

time_span time_span::from_seconds( const int32_t v ) {
    return time_span( v * static_cast<int64_t>(tick::SECOND_TO_MICRO_SECONDS ));
}
time_span time_span::from_minutes( const int32_t v ) {
    return time_span( v * static_cast<int64_t>(tick::MINUTE_TO_MICRO_SECONDS ));
}
time_span time_span::from_hours( const int32_t v ) {
    return time_span( v * static_cast<int64_t>(tick::HOUR_TO_MICRO_SECONDS ));
}
time_span time_span::from_days( const int32_t v ) {
    return time_span( v * static_cast<int64_t>(tick::DAY_TO_MICRO_SECONDS ));
}
time_span time_span::infinite( void ) {
	return time_span( INFINITE_DELTA );
}

timeval time_span::to_timeval( void ) const {
    timeval tval;
	tval.tv_sec  = static_cast<int>(this->total_seconds());
	tval.tv_usec = static_cast<int>(this->total_micro_seconds() % tick::SECOND_TO_MICRO_SECONDS);
    return tval;
}

bool time_span::operator== ( const time_span& rhs ) const{
    return _delta == rhs._delta;
}
bool time_span::operator!=( const time_span& rhs ) const{
    return _delta != rhs._delta;
}
bool time_span::operator> ( const time_span& rhs ) const{
    return _delta > rhs._delta;
}
bool time_span::operator>=( const time_span& rhs ) const{
    return _delta >= rhs._delta;
}
bool time_span::operator< ( const time_span& rhs ) const{
    return _delta < rhs._delta;
}
bool time_span::operator<=( const time_span& rhs ) const{
    return _delta <= rhs._delta;
}

time_span time_span::operator*( const int32_t times ) const{
    return time_span( _delta * times );
}
time_span& time_span::operator*=( const int32_t times ) {
    _delta *= times;
    return *this;
}   

time_span  time_span::operator/ ( const int32_t times ) const{
    return time_span( _delta / (times > 0? times : 1)); //max( 1 , times ) );
}

time_span& time_span::operator/=( const int32_t times ) {
    _delta /= times > 0 ? times : 1;
    return *this;
}

int64_t  time_span::operator/ ( const time_span& times ) const {
    return _delta / ( times._delta > 0 ? times._delta : 1 );
}

time_span  time_span::operator+ ( const time_span& rhs ) const{
    return time_span( _delta + rhs._delta );
}

time_span& time_span::operator+=( const time_span& rhs ) {
    _delta += rhs._delta;
    return *this;
}

time_span  time_span::operator- ( const time_span& rhs ) const{
    return time_span( _delta - rhs._delta );
}

time_span& time_span::operator-=( const time_span& rhs ) {
    _delta -= rhs._delta;
    return *this;
}

date_time  time_span::operator+ ( const date_time& rhs ) const {
    return rhs + *this;
}

time_span  time_span::operator- ( void ) const {
    return time_span( -_delta );
}

int64_t time_span::micro_seconds( void ) const {
	return  total_micro_seconds() % 1000;
}
int64_t time_span::milli_seconds( void ) const {
    return total_milli_seconds() % 1000;
}
int64_t time_span::seconds( void ) const {
    return total_seconds() % 60;
}
int64_t time_span::minutes( void ) const {
    return total_minutes() % 60;
}
int64_t time_span::hours( void ) const {
    return total_hours() % 24;
}
int64_t time_span::days( void ) const {
    return total_days();
}

int64_t time_span::total_micro_seconds( void ) const {
    return _delta;
}
int64_t time_span::total_milli_seconds( void ) const {
    return _delta / static_cast<int64_t>(tick::MILLI_SECOND_TO_MICRO_SECONDS);
}
int64_t time_span::total_seconds( void ) const {
    return _delta / static_cast<int64_t>(tick::SECOND_TO_MICRO_SECONDS);
}
int64_t time_span::total_minutes( void ) const {
    return _delta / static_cast<int64_t>(tick::MINUTE_TO_MICRO_SECONDS);
}
int64_t time_span::total_hours( void ) const {
    return _delta / static_cast<int64_t>(tick::HOUR_TO_MICRO_SECONDS);
}
int64_t time_span::total_days( void ) const {
    return _delta / static_cast<int64_t>(tick::DAY_TO_MICRO_SECONDS);
}


}
Example #10
0
time_span time_span::from_micro_seconds( const int64_t v ) {
    return time_span( v );
}
Example #11
0
time_span  time_span::operator- ( void ) const {
    return time_span( -_delta );
}
Example #12
0
time_span  time_span::operator- ( const time_span& rhs ) const{
    return time_span( _delta - rhs._delta );
}
Example #13
0
time_span  time_span::operator/ ( const int32_t times ) const{
    return time_span( _delta / (times > 0? times : 1)); //max( 1 , times ) );
}
Example #14
0
time_span time_span::operator*( const int32_t times ) const{
    return time_span( _delta * times );
}
Example #15
0
time_span time_span::infinite( void ) {
	return time_span( INFINITE_DELTA );
}