1 | *** boost/date_time/time_facet.hpp.orig Wed Apr 23 21:42:46 2008
|
---|
2 | --- boost/date_time/time_facet.hpp Wed Apr 23 23:26:03 2008
|
---|
3 | ***************
|
---|
4 | *** 16,21 ****
|
---|
5 | --- 16,22 ----
|
---|
6 | #include <sstream>
|
---|
7 | #include <iomanip>
|
---|
8 | #include <exception>
|
---|
9 | + #include <limits>
|
---|
10 |
|
---|
11 | namespace boost {
|
---|
12 | namespace date_time {
|
---|
13 | ***************
|
---|
14 | *** 416,421 ****
|
---|
15 | --- 417,435 ----
|
---|
16 | positive_sign);
|
---|
17 | }
|
---|
18 |
|
---|
19 | + if (format.find("%H") != string_type::npos) {
|
---|
20 | + /*
|
---|
21 | + * It is possible for a time duration to span more then 24 hours.
|
---|
22 | + * Standard time_put::put is obliged to behave the same as strftime
|
---|
23 | + * (See ISO 14882-2003 22.2.5.3.1 par. 1) and strftime's behavior is
|
---|
24 | + * unspecified for the case when tm_hour field is outside 0-23 range
|
---|
25 | + * (See ISO 9899-1999 7.23.3.5 par. 3). So we must output %H here
|
---|
26 | + * ourself.
|
---|
27 | + */
|
---|
28 | + string_type hours_str = hours_as_string(a_time_dur);
|
---|
29 | + boost::algorithm::replace_all(format, "%H", hours_str);
|
---|
30 | + }
|
---|
31 | +
|
---|
32 | string_type frac_str;
|
---|
33 | if (format.find(seconds_with_fractional_seconds_format) != string_type::npos) {
|
---|
34 | // replace %s with %S.nnn
|
---|
35 | ***************
|
---|
36 | *** 500,505 ****
|
---|
37 | --- 514,539 ----
|
---|
38 | return ss.str();
|
---|
39 | }
|
---|
40 |
|
---|
41 | + static
|
---|
42 | + string_type
|
---|
43 | + hours_as_string(const time_duration_type& a_time, int width = 2)
|
---|
44 | + {
|
---|
45 | + typename time_duration_type::hour_type hours = a_time.hours();
|
---|
46 | +
|
---|
47 | + std::basic_ostringstream<char_type> ss;
|
---|
48 | + ss.imbue(std::locale::classic()); // don't want any formatting
|
---|
49 | + ss << std::setw(width)
|
---|
50 | + << std::setfill(static_cast<char_type>('0'));
|
---|
51 | + #if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
|
---|
52 | + // JDG [7/6/02 VC++ compatibility]
|
---|
53 | + char_type buff[34];
|
---|
54 | + ss << _i64toa(static_cast<boost::int64_t>(hours), buff, 10);
|
---|
55 | + #else
|
---|
56 | + ss << hours;
|
---|
57 | + #endif
|
---|
58 | + return ss.str();
|
---|
59 | + }
|
---|
60 | +
|
---|
61 | private:
|
---|
62 | string_type m_time_duration_format;
|
---|
63 |
|
---|
64 | ***************
|
---|
65 | *** 705,714 ****
|
---|
66 | c = *sitr;
|
---|
67 | }
|
---|
68 |
|
---|
69 | ! long hour = 0;
|
---|
70 | ! long min = 0;
|
---|
71 | ! long sec = 0;
|
---|
72 | ! typename time_duration_type::fractional_seconds_type frac(0);
|
---|
73 |
|
---|
74 | typedef std::num_get<CharT, InItrT> num_get;
|
---|
75 | if(!std::has_facet<num_get>(a_ios.getloc())) {
|
---|
76 | --- 739,752 ----
|
---|
77 | c = *sitr;
|
---|
78 | }
|
---|
79 |
|
---|
80 | ! typedef typename time_duration_type::hour_type hour_type;
|
---|
81 | ! typedef typename time_duration_type::min_type min_type;
|
---|
82 | ! typedef typename time_duration_type::sec_type sec_type;
|
---|
83 | !
|
---|
84 | ! hour_type hour = 0;
|
---|
85 | ! min_type min = 0;
|
---|
86 | ! sec_type sec = 0;
|
---|
87 | ! fractional_seconds_type frac(0);
|
---|
88 |
|
---|
89 | typedef std::num_get<CharT, InItrT> num_get;
|
---|
90 | if(!std::has_facet<num_get>(a_ios.getloc())) {
|
---|
91 | ***************
|
---|
92 | *** 726,732 ****
|
---|
93 | case 'H':
|
---|
94 | {
|
---|
95 | match_results mr;
|
---|
96 | ! hour = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
|
---|
97 | if(hour == -1){
|
---|
98 | return check_special_value(sitr, stream_end, td, c);
|
---|
99 | }
|
---|
100 | --- 764,772 ----
|
---|
101 | case 'H':
|
---|
102 | {
|
---|
103 | match_results mr;
|
---|
104 | ! // A period may span more than 24 hours.
|
---|
105 | ! hour = var_string_to_int<hour_type, CharT>(sitr, stream_end,
|
---|
106 | ! std::numeric_limits<hour_type>::digits10);
|
---|
107 | if(hour == -1){
|
---|
108 | return check_special_value(sitr, stream_end, td, c);
|
---|
109 | }
|
---|