Ticket #3126: main.cpp

File main.cpp, 723 bytes (added by mbd@…, 13 years ago)

Minimal program that illustrates problems when formatting a time_duration with more than 99 hours. Make sure to use a debug build of boost to get an assertion.

Line 
1// time_duration can not be formatted with boost_format for more than 99 hours
2#include <iostream>
3#include <boost/format.hpp>
4#include <boost/date_time/posix_time/posix_time.hpp>
5
6int main() {
7 // Output for up to 24 is ok
8 std::cout << boost::format( "%1%" ) % boost::posix_time::time_duration( 23, 59, 59, 9999 ) << std::endl;
9 // This is still working
10 std::cout << boost::format( "%1%" ) % boost::posix_time::time_duration( 99, 59, 59, 9999 ) << std::endl;
11 // Stopped working as of revision https://svn.boost.org/trac/boost/changeset/49874
12 // This asserts with a debug build, in time_facet
13 std::cout << boost::format( "%1%" ) % boost::posix_time::time_duration( 100, 0, 0, 0 ) << std::endl;
14}
15