JayBeams  0.1
Another project to have fun coding.
timestamp.cpp
Go to the documentation of this file.
1 #include "jb/itch5/timestamp.hpp"
2 
3 #include <iomanip>
4 #include <sstream>
5 #include <stdexcept>
6 
7 template <>
9  auto full_day = std::chrono::duration_cast<std::chrono::nanoseconds>(
10  std::chrono::seconds(24 * 3600));
11 
12  if (t.ts < full_day) {
13  return;
14  }
15  std::ostringstream os;
16  os << "out of range timestamp <" << t.ts.count() << "> expected value in [0,"
17  << full_day.count() << ") range";
18  throw std::range_error(os.str());
19 }
20 
21 std::ostream& jb::itch5::operator<<(std::ostream& os, timestamp const& x) {
22  auto sec = std::chrono::duration_cast<std::chrono::seconds>(x.ts);
23  auto nn = (x.ts - sec).count();
24 
25  auto t = sec.count();
26  auto ss = t % 60;
27  t /= 60;
28  auto mm = t % 60;
29  t /= 60;
30  auto hh = t;
31  return os << std::setw(2) << std::setfill('0') << hh << std::setw(2)
32  << std::setfill('0') << mm << std::setw(2) << std::setfill('0')
33  << ss << "." << std::setw(9) << std::setfill('0') << nn;
34 }
void check_timestamp_range< true >(timestamp const &t)
Provide an active implementation of jb::itch5::check_timestamp_range<>
Definition: timestamp.cpp:8
Represent a ITCH-5.0 timestamp.
Definition: timestamp.hpp:17
std::chrono::nanoseconds ts
Definition: timestamp.hpp:18
std::ostream & operator<<(std::ostream &os, add_order_message const &x)
Streaming operator for jb::itch5::add_order_message.