25 Time library [time]

25.9 Class template time_­of_­day [time.tod]

25.9.6 Formatted output [time.tod.io]

template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const time_of_day<hours>& t);
Effects: If t is a 24-hour time, outputs to os according to the format "%H00" ([time.format]).
Otherwise outputs to os according to the format "%I%p" ([time.format]).
Returns: os.
[ Example
:
for (hours h : {1h, 18h}) {
  time_of_day<hours> tod(h);
  os << tod << '\n';
  tod.make12();
  os << tod << '\n';
}
Produces the output:
0100
1am
1800
6pm
— end example
 ]
template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const time_of_day<minutes>& t);
Effects: If t is a 24-hour time, outputs to os according to the format "%H:%M" ([time.format]).
Otherwise outputs to os according to the format "%I:%M%p" ([time.format]).
Returns: os.
[ Example
:
for (minutes m : {68min, 1095min}) {
  time_of_day<minutes> tod(m);
  os << tod << '\n';
  tod.make12();
  os << tod << '\n';
}
Produces the output:
01:08
1:08am
18:15
6:15pm
— end example
 ]
template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const time_of_day<seconds>& t);
Effects: If t is a 24-hour time, outputs to os according to the format "%T" ([time.format]).
Otherwise outputs to os according to the format "%I:%M:%S%p" ([time.format]).
Returns: os.
[ Example
:
for (seconds s : {4083s, 65745s}) {
  time_of_day<seconds> tod(s);
  os << tod << '\n';
  tod.make12();
  os << tod << '\n';
}
Produces the output:
01:08:03
1:08:03am
18:15:45
6:15:45pm
— end example
 ]
template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const time_of_day<duration<Rep, Period>>& t);
Effects: If t is a 24-hour time, outputs to os according to the format "%T" ([time.format]).
Otherwise outputs to os according to the format "%I:%M:%S%p" ([time.format]).
Returns: os.
[ Example
:
for (milliseconds ms : {4083007ms, 65745123ms}) {
  time_of_day<seconds> tod(ms);
  os << tod << '\n';
  tod.make12();
  os << tod << '\n';
}
Produces the output:
01:08:03.007
1:08:03.007am
18:15:45.123
6:15:45.123pm
— end example
 ]