-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxcast.cpp
54 lines (43 loc) · 1.17 KB
/
xcast.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "xcast.h"
#include <sstream>
#include <iomanip>
using namespace std;
bool xcast::PacketTime::operator<(const PacketTime& rhs) const
{
if( (y_ > -1 && rhs.y_ > -1 ) && (y_ != rhs.y_) )
return y_ < rhs.y_;
if( (m_ > -1 && rhs.m_ > -1) && (m_ != rhs.m_) )
return m_ < rhs.m_;
if( (d_ > -1 && rhs.d_ > -1) && (d_ != rhs.d_) )
return d_ < rhs.d_;
if( hh_ != rhs.hh_ )
return hh_ < rhs.hh_;
if( mm_ != rhs.mm_ )
return mm_ < rhs.mm_;
if( (ss_ > -1 && rhs.ss_ > -1) && (ss_ != rhs.ss_) )
return ss_ < rhs.ss_;
if( ms_ > -1 && rhs.ms_ > -1 )
return ms_ < rhs.ms_;
return false;
}
std::string xcast::PacketTime::format() const
{
stringstream ss;
if( y_ > -1 )
ss << setw(4) << setfill('0') << y_ << "/";
else
ss << " ";
if( m_ > -1 )
ss << setw(2) << setfill('0') << m_ << "/" ;
else
ss << " ";
if( d_ > -1 )
ss << setw(2) << setfill('0') << d_ << " " ;
else
ss << " ";
ss << setw(2) << setfill('0') << hh_ << ":"
<< setw(2) << setfill('0') << mm_ << ":"
<< setw(2) << setfill('0') << ss_ << "."
<< setw(3) << setfill('0') << ms_;
return ss.str();
}