Example #1
0
//
/// Inserts time t into output stream os.
//
_OWLCFUNC(tostream &) operator << (tostream & s, const TTime & t)
{
  // We use an ostrstream to format into buf so that
  // we don't affect the ostream's width setting.
  //
  tostringstream out;

  // First print the date if requested:
  //
  if(TTime::PrintDateFlag)
      out << TDate(t) << _T(" ");

  unsigned hh = t.Hour();
  out << (hh <= 12 ? hh : hh-12) << _T(':');
  out << setfill(_T('0'));
  out << setw(2);
  out << t.Minute() << _T(':');
  out << setw(2);
  out << t.Second() << _T(' ');
  out << setfill(_T(' '));
  out << ( hh<12 ? _T("am") : _T("pm"));

  s << out.str();
  return s;
}