[Boost-bugs] [Boost C++ Libraries] #6664: std::setw() is ignored by operator<< for ptime, time_duration, and date

Subject: [Boost-bugs] [Boost C++ Libraries] #6664: std::setw() is ignored by operator<< for ptime, time_duration, and date
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-03-08 21:15:41


#6664: std::setw() is ignored by operator<< for ptime, time_duration, and date
----------------------------------------------------+-----------------------
 Reporter: Mark van Dijk <mark.van.dijk@…> | Owner: az_sw_dude
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: date_time
  Version: Boost 1.48.0 | Severity: Cosmetic
 Keywords: stream manipulator ptime setw |
----------------------------------------------------+-----------------------
 The following complete program demonstrates the issue. when using
 operator<< to display a ptime/time_duration/date, then the setw()
 manipulator is ignored.

 My development environment is boost 1.48, building a 32-bit app on Win7
 (x64) under VS2008.

 I consider this a cosmetic issue as there is a very simple work-aroud -
 simply manually convert the ptime/date/duration object to a string before
 inserting it into the ostream object.

 {{{
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/date_time/gregorian/gregorian.hpp>
 #include <iomanip>
 #include <iostream>
 #include <string>


 int main()
 {

     boost::posix_time::ptime const now =
 boost::posix_time::second_clock::local_time();

     std::cout
         << "\ncorrectly formatted: " << std::setw(40) <<
 boost::posix_time::to_simple_string(now)
         << "\nptime: " << std::setw(40) << now
         << "\ntime_duration: " << std::setw(40) << now.date()
         << "\ndate: " << std::setw(40) << now.time_of_day()
         << std::endl;
 }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6664>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC