JayBeams  0.1
Another project to have fun coding.
as_hhmmss.cpp
Go to the documentation of this file.
1 #include "jb/as_hhmmss.hpp"
2 
3 #include <boost/io/ios_state.hpp>
4 
5 #include <iomanip>
6 #include <iostream>
7 
8 std::ostream& jb::operator<<(std::ostream& os, jb::as_hhmmssu const& x) {
9  boost::io::ios_flags_saver saver(os);
10  auto usec = x.t.count() % 1000000;
11  return os << jb::as_hhmmss(x.t) << '.' << std::setw(6) << std::setfill('0')
12  << usec;
13 }
14 
15 std::ostream& jb::operator<<(std::ostream& os, jb::as_hhmmss const& x) {
16  boost::io::ios_flags_saver saver(os);
17  auto t = x.t.count() / 1000000;
18  auto ss = t % 60;
19  t /= 60;
20  auto mm = t % 60;
21  t /= 60;
22  auto hh = t;
23  return os << std::setw(2) << std::setfill('0') << hh << std::setw(2)
24  << std::setfill('0') << mm << std::setw(2) << std::setfill('0')
25  << ss;
26 }
27 
28 std::ostream& jb::operator<<(std::ostream& os, jb::as_hh_mm_ss_u const& x) {
29  boost::io::ios_flags_saver saver(os);
30  auto usec = x.t.count() % 1000000;
31  auto t = x.t.count() / 1000000;
32  auto ss = t % 60;
33  t /= 60;
34  auto mm = t % 60;
35  t /= 60;
36  auto hh = t;
37  return os << std::setw(2) << std::setfill('0') << hh << ":" << std::setw(2)
38  << std::setfill('0') << mm << ":" << std::setw(2)
39  << std::setfill('0') << ss << "." << std::setw(6)
40  << std::setfill('0') << usec;
41 }
std::chrono::microseconds t
Definition: as_hhmmss.hpp:72
std::chrono::microseconds t
Definition: as_hhmmss.hpp:26
std::ostream & operator<<(std::ostream &os, as_hhmmssu const &x)
Format as_hhmmssu into an iostream.
Definition: as_hhmmss.cpp:8
std::chrono::microseconds t
Definition: as_hhmmss.hpp:49
Helper class to print time durations s in HHMMSS format.
Definition: as_hhmmss.hpp:35
Helper class to print time durations in a HHMMSS.UUUUUU format.
Definition: as_hhmmss.hpp:12
Helper class to print time durations in HH:MM:SS.UUUUUU format.
Definition: as_hhmmss.hpp:58