1
#ifndef DATE_TIME_GREGORIAN_IO_HPP__
2
#define DATE_TIME_GREGORIAN_IO_HPP__
4
/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
5
* Use, modification and distribution is subject to the
6
* Boost Software License, Version 1.0. (See accompanying
7
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
8
* Author: Jeff Garland, Bart Garst
9
* $Date: 2008-11-12 14:37:53 -0500 (Wed, 12 Nov 2008) $
14
#include <iterator> // i/ostreambuf_iterator
15
#include <boost/io/ios_state.hpp>
16
#include <boost/date_time/date_facet.hpp>
17
#include <boost/date_time/period_parser.hpp>
18
#include <boost/date_time/period_formatter.hpp>
19
#include <boost/date_time/special_values_parser.hpp>
20
#include <boost/date_time/special_values_formatter.hpp>
21
#include <boost/date_time/gregorian/gregorian_types.hpp>
22
#include <boost/date_time/gregorian/conversion.hpp> // to_tm will be needed in the facets
28
typedef boost::date_time::period_formatter<wchar_t> wperiod_formatter;
29
typedef boost::date_time::period_formatter<char> period_formatter;
31
typedef boost::date_time::date_facet<date,wchar_t> wdate_facet;
32
typedef boost::date_time::date_facet<date,char> date_facet;
34
typedef boost::date_time::period_parser<date,char> period_parser;
35
typedef boost::date_time::period_parser<date,wchar_t> wperiod_parser;
37
typedef boost::date_time::special_values_formatter<char> special_values_formatter;
38
typedef boost::date_time::special_values_formatter<wchar_t> wspecial_values_formatter;
40
typedef boost::date_time::special_values_parser<date,char> special_values_parser;
41
typedef boost::date_time::special_values_parser<date,wchar_t> wspecial_values_parser;
43
typedef boost::date_time::date_input_facet<date,char> date_input_facet;
44
typedef boost::date_time::date_input_facet<date,wchar_t> wdate_input_facet;
46
template <class CharT, class TraitsT>
47
inline std::basic_ostream<CharT, TraitsT>&
48
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::date& d) {
49
boost::io::ios_flags_saver iflags(os);
50
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
51
std::ostreambuf_iterator<CharT> output_itr(os);
52
if (std::has_facet<custom_date_facet>(os.getloc()))
53
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), d);
55
//instantiate a custom facet for dealing with dates since the user
56
//has not put one in the stream so far. This is for efficiency
57
//since we would always need to reconstruct for every date
58
//if the locale did not already exist. Of course this will be overridden
59
//if the user imbues at some later point. With the default settings
60
//for the facet the resulting format will be the same as the
61
//std::time_facet settings.
62
custom_date_facet* f = new custom_date_facet();
63
std::locale l = std::locale(os.getloc(), f);
65
f->put(output_itr, os, os.fill(), d);
70
//! input operator for date
71
template <class CharT, class Traits>
73
std::basic_istream<CharT, Traits>&
74
operator>>(std::basic_istream<CharT, Traits>& is, date& d)
76
boost::io::ios_flags_saver iflags(is);
77
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
80
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
82
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
83
if(std::has_facet<date_input_facet>(is.getloc())) {
84
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, d);
87
date_input_facet* f = new date_input_facet();
88
std::locale l = std::locale(is.getloc(), f);
90
f->get(sit, str_end, is, d);
94
// mask tells us what exceptions are turned on
95
std::ios_base::iostate exception_mask = is.exceptions();
96
// if the user wants exceptions on failbit, we'll rethrow our
97
// date_time exception & set the failbit
98
if(std::ios_base::failbit & exception_mask) {
99
try { is.setstate(std::ios_base::failbit); }
100
catch(std::ios_base::failure&) {} // ignore this one
101
throw; // rethrow original exception
104
// if the user want's to fail quietly, we simply set the failbit
105
is.setstate(std::ios_base::failbit);
113
template <class CharT, class TraitsT>
114
inline std::basic_ostream<CharT, TraitsT>&
115
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::date_duration& dd) {
116
boost::io::ios_flags_saver iflags(os);
117
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
118
std::ostreambuf_iterator<CharT> output_itr(os);
119
if (std::has_facet<custom_date_facet>(os.getloc()))
120
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), dd);
122
custom_date_facet* f = new custom_date_facet();
123
std::locale l = std::locale(os.getloc(), f);
125
f->put(output_itr, os, os.fill(), dd);
131
//! input operator for date_duration
132
template <class CharT, class Traits>
134
std::basic_istream<CharT, Traits>&
135
operator>>(std::basic_istream<CharT, Traits>& is, date_duration& dd)
137
boost::io::ios_flags_saver iflags(is);
138
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
141
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
143
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
144
if(std::has_facet<date_input_facet>(is.getloc())) {
145
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, dd);
148
date_input_facet* f = new date_input_facet();
149
std::locale l = std::locale(is.getloc(), f);
151
f->get(sit, str_end, is, dd);
155
std::ios_base::iostate exception_mask = is.exceptions();
156
if(std::ios_base::failbit & exception_mask) {
157
try { is.setstate(std::ios_base::failbit); }
158
catch(std::ios_base::failure&) {}
159
throw; // rethrow original exception
162
is.setstate(std::ios_base::failbit);
170
template <class CharT, class TraitsT>
171
inline std::basic_ostream<CharT, TraitsT>&
172
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::date_period& dp) {
173
boost::io::ios_flags_saver iflags(os);
174
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
175
std::ostreambuf_iterator<CharT> output_itr(os);
176
if (std::has_facet<custom_date_facet>(os.getloc()))
177
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), dp);
179
//instantiate a custom facet for dealing with date periods since the user
180
//has not put one in the stream so far. This is for efficiency
181
//since we would always need to reconstruct for every time period
182
//if the local did not already exist. Of course this will be overridden
183
//if the user imbues at some later point. With the default settings
184
//for the facet the resulting format will be the same as the
185
//std::time_facet settings.
186
custom_date_facet* f = new custom_date_facet();
187
std::locale l = std::locale(os.getloc(), f);
189
f->put(output_itr, os, os.fill(), dp);
195
//! input operator for date_period
196
template <class CharT, class Traits>
198
std::basic_istream<CharT, Traits>&
199
operator>>(std::basic_istream<CharT, Traits>& is, date_period& dp)
201
boost::io::ios_flags_saver iflags(is);
202
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
205
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
207
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
208
if(std::has_facet<date_input_facet>(is.getloc())) {
209
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, dp);
212
date_input_facet* f = new date_input_facet();
213
std::locale l = std::locale(is.getloc(), f);
215
f->get(sit, str_end, is, dp);
219
std::ios_base::iostate exception_mask = is.exceptions();
220
if(std::ios_base::failbit & exception_mask) {
221
try { is.setstate(std::ios_base::failbit); }
222
catch(std::ios_base::failure&) {}
223
throw; // rethrow original exception
226
is.setstate(std::ios_base::failbit);
234
/********** small gregorian types **********/
236
template <class CharT, class TraitsT>
237
inline std::basic_ostream<CharT, TraitsT>&
238
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::greg_month& gm) {
239
boost::io::ios_flags_saver iflags(os);
240
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
241
std::ostreambuf_iterator<CharT> output_itr(os);
242
if (std::has_facet<custom_date_facet>(os.getloc()))
243
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), gm);
245
custom_date_facet* f = new custom_date_facet();//-> 10/1074199752/32 because year & day not initialized in put(...)
246
//custom_date_facet* f = new custom_date_facet("%B");
247
std::locale l = std::locale(os.getloc(), f);
249
f->put(output_itr, os, os.fill(), gm);
254
//! input operator for greg_month
255
template <class CharT, class Traits>
257
std::basic_istream<CharT, Traits>&
258
operator>>(std::basic_istream<CharT, Traits>& is, greg_month& m)
260
boost::io::ios_flags_saver iflags(is);
261
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
264
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
266
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
267
if(std::has_facet<date_input_facet>(is.getloc())) {
268
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, m);
271
date_input_facet* f = new date_input_facet();
272
std::locale l = std::locale(is.getloc(), f);
274
f->get(sit, str_end, is, m);
278
std::ios_base::iostate exception_mask = is.exceptions();
279
if(std::ios_base::failbit & exception_mask) {
280
try { is.setstate(std::ios_base::failbit); }
281
catch(std::ios_base::failure&) {}
282
throw; // rethrow original exception
285
is.setstate(std::ios_base::failbit);
294
template <class CharT, class TraitsT>
295
inline std::basic_ostream<CharT, TraitsT>&
296
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::greg_weekday& gw) {
297
boost::io::ios_flags_saver iflags(os);
298
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
299
std::ostreambuf_iterator<CharT> output_itr(os);
300
if (std::has_facet<custom_date_facet>(os.getloc()))
301
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), gw);
303
custom_date_facet* f = new custom_date_facet();
304
std::locale l = std::locale(os.getloc(), f);
306
f->put(output_itr, os, os.fill(), gw);
311
//! input operator for greg_weekday
312
template <class CharT, class Traits>
314
std::basic_istream<CharT, Traits>&
315
operator>>(std::basic_istream<CharT, Traits>& is, greg_weekday& wd)
317
boost::io::ios_flags_saver iflags(is);
318
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
321
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
323
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
324
if(std::has_facet<date_input_facet>(is.getloc())) {
325
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, wd);
328
date_input_facet* f = new date_input_facet();
329
std::locale l = std::locale(is.getloc(), f);
331
f->get(sit, str_end, is, wd);
335
std::ios_base::iostate exception_mask = is.exceptions();
336
if(std::ios_base::failbit & exception_mask) {
337
try { is.setstate(std::ios_base::failbit); }
338
catch(std::ios_base::failure&) {}
339
throw; // rethrow original exception
342
is.setstate(std::ios_base::failbit);
350
//NOTE: output operator for greg_day was not necessary
352
//! input operator for greg_day
353
template <class CharT, class Traits>
355
std::basic_istream<CharT, Traits>&
356
operator>>(std::basic_istream<CharT, Traits>& is, greg_day& gd)
358
boost::io::ios_flags_saver iflags(is);
359
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
362
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
364
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
365
if(std::has_facet<date_input_facet>(is.getloc())) {
366
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, gd);
369
date_input_facet* f = new date_input_facet();
370
std::locale l = std::locale(is.getloc(), f);
372
f->get(sit, str_end, is, gd);
376
std::ios_base::iostate exception_mask = is.exceptions();
377
if(std::ios_base::failbit & exception_mask) {
378
try { is.setstate(std::ios_base::failbit); }
379
catch(std::ios_base::failure&) {}
380
throw; // rethrow original exception
383
is.setstate(std::ios_base::failbit);
391
//NOTE: output operator for greg_year was not necessary
393
//! input operator for greg_year
394
template <class CharT, class Traits>
396
std::basic_istream<CharT, Traits>&
397
operator>>(std::basic_istream<CharT, Traits>& is, greg_year& gy)
399
boost::io::ios_flags_saver iflags(is);
400
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
403
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
405
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
406
if(std::has_facet<date_input_facet>(is.getloc())) {
407
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, gy);
410
date_input_facet* f = new date_input_facet();
411
std::locale l = std::locale(is.getloc(), f);
413
f->get(sit, str_end, is, gy);
417
std::ios_base::iostate exception_mask = is.exceptions();
418
if(std::ios_base::failbit & exception_mask) {
419
try { is.setstate(std::ios_base::failbit); }
420
catch(std::ios_base::failure&) {}
421
throw; // rethrow original exception
424
is.setstate(std::ios_base::failbit);
432
/********** date generator types **********/
434
template <class CharT, class TraitsT>
435
inline std::basic_ostream<CharT, TraitsT>&
436
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::partial_date& pd) {
437
boost::io::ios_flags_saver iflags(os);
438
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
439
std::ostreambuf_iterator<CharT> output_itr(os);
440
if (std::has_facet<custom_date_facet>(os.getloc()))
441
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), pd);
443
custom_date_facet* f = new custom_date_facet();
444
std::locale l = std::locale(os.getloc(), f);
446
f->put(output_itr, os, os.fill(), pd);
451
//! input operator for partial_date
452
template <class CharT, class Traits>
454
std::basic_istream<CharT, Traits>&
455
operator>>(std::basic_istream<CharT, Traits>& is, partial_date& pd)
457
boost::io::ios_flags_saver iflags(is);
458
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
461
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
463
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
464
if(std::has_facet<date_input_facet>(is.getloc())) {
465
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, pd);
468
date_input_facet* f = new date_input_facet();
469
std::locale l = std::locale(is.getloc(), f);
471
f->get(sit, str_end, is, pd);
475
std::ios_base::iostate exception_mask = is.exceptions();
476
if(std::ios_base::failbit & exception_mask) {
477
try { is.setstate(std::ios_base::failbit); }
478
catch(std::ios_base::failure&) {}
479
throw; // rethrow original exception
482
is.setstate(std::ios_base::failbit);
490
template <class CharT, class TraitsT>
491
inline std::basic_ostream<CharT, TraitsT>&
492
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::nth_day_of_the_week_in_month& nkd) {
493
boost::io::ios_flags_saver iflags(os);
494
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
495
std::ostreambuf_iterator<CharT> output_itr(os);
496
if (std::has_facet<custom_date_facet>(os.getloc()))
497
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), nkd);
499
custom_date_facet* f = new custom_date_facet();
500
std::locale l = std::locale(os.getloc(), f);
502
f->put(output_itr, os, os.fill(), nkd);
507
//! input operator for nth_day_of_the_week_in_month
508
template <class CharT, class Traits>
510
std::basic_istream<CharT, Traits>&
511
operator>>(std::basic_istream<CharT, Traits>& is,
512
nth_day_of_the_week_in_month& nday)
514
boost::io::ios_flags_saver iflags(is);
515
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
518
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
520
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
521
if(std::has_facet<date_input_facet>(is.getloc())) {
522
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, nday);
525
date_input_facet* f = new date_input_facet();
526
std::locale l = std::locale(is.getloc(), f);
528
f->get(sit, str_end, is, nday);
532
std::ios_base::iostate exception_mask = is.exceptions();
533
if(std::ios_base::failbit & exception_mask) {
534
try { is.setstate(std::ios_base::failbit); }
535
catch(std::ios_base::failure&) {}
536
throw; // rethrow original exception
539
is.setstate(std::ios_base::failbit);
548
template <class CharT, class TraitsT>
549
inline std::basic_ostream<CharT, TraitsT>&
550
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::first_day_of_the_week_in_month& fkd) {
551
boost::io::ios_flags_saver iflags(os);
552
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
553
std::ostreambuf_iterator<CharT> output_itr(os);
554
if (std::has_facet<custom_date_facet>(os.getloc()))
555
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), fkd);
557
custom_date_facet* f = new custom_date_facet();
558
std::locale l = std::locale(os.getloc(), f);
560
f->put(output_itr, os, os.fill(), fkd);
565
//! input operator for first_day_of_the_week_in_month
566
template <class CharT, class Traits>
568
std::basic_istream<CharT, Traits>&
569
operator>>(std::basic_istream<CharT, Traits>& is,
570
first_day_of_the_week_in_month& fkd)
572
boost::io::ios_flags_saver iflags(is);
573
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
576
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
578
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
579
if(std::has_facet<date_input_facet>(is.getloc())) {
580
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fkd);
583
date_input_facet* f = new date_input_facet();
584
std::locale l = std::locale(is.getloc(), f);
586
f->get(sit, str_end, is, fkd);
590
std::ios_base::iostate exception_mask = is.exceptions();
591
if(std::ios_base::failbit & exception_mask) {
592
try { is.setstate(std::ios_base::failbit); }
593
catch(std::ios_base::failure&) {}
594
throw; // rethrow original exception
597
is.setstate(std::ios_base::failbit);
606
template <class CharT, class TraitsT>
607
inline std::basic_ostream<CharT, TraitsT>&
608
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::last_day_of_the_week_in_month& lkd) {
609
boost::io::ios_flags_saver iflags(os);
610
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
611
std::ostreambuf_iterator<CharT> output_itr(os);
612
if (std::has_facet<custom_date_facet>(os.getloc()))
613
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), lkd);
615
custom_date_facet* f = new custom_date_facet();
616
std::locale l = std::locale(os.getloc(), f);
618
f->put(output_itr, os, os.fill(), lkd);
623
//! input operator for last_day_of_the_week_in_month
624
template <class CharT, class Traits>
626
std::basic_istream<CharT, Traits>&
627
operator>>(std::basic_istream<CharT, Traits>& is,
628
last_day_of_the_week_in_month& lkd)
630
boost::io::ios_flags_saver iflags(is);
631
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
634
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
636
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
637
if(std::has_facet<date_input_facet>(is.getloc())) {
638
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, lkd);
641
date_input_facet* f = new date_input_facet();
642
std::locale l = std::locale(is.getloc(), f);
644
f->get(sit, str_end, is, lkd);
648
std::ios_base::iostate exception_mask = is.exceptions();
649
if(std::ios_base::failbit & exception_mask) {
650
try { is.setstate(std::ios_base::failbit); }
651
catch(std::ios_base::failure&) {}
652
throw; // rethrow original exception
655
is.setstate(std::ios_base::failbit);
664
template <class CharT, class TraitsT>
665
inline std::basic_ostream<CharT, TraitsT>&
666
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::first_day_of_the_week_after& fda) {
667
boost::io::ios_flags_saver iflags(os);
668
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
669
std::ostreambuf_iterator<CharT> output_itr(os);
670
if (std::has_facet<custom_date_facet>(os.getloc())) {
671
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), fda);
674
custom_date_facet* f = new custom_date_facet();
675
std::locale l = std::locale(os.getloc(), f);
677
f->put(output_itr, os, os.fill(), fda);
682
//! input operator for first_day_of_the_week_after
683
template <class CharT, class Traits>
685
std::basic_istream<CharT, Traits>&
686
operator>>(std::basic_istream<CharT, Traits>& is,
687
first_day_of_the_week_after& fka)
689
boost::io::ios_flags_saver iflags(is);
690
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
693
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
695
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
696
if(std::has_facet<date_input_facet>(is.getloc())) {
697
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fka);
700
date_input_facet* f = new date_input_facet();
701
std::locale l = std::locale(is.getloc(), f);
703
f->get(sit, str_end, is, fka);
707
std::ios_base::iostate exception_mask = is.exceptions();
708
if(std::ios_base::failbit & exception_mask) {
709
try { is.setstate(std::ios_base::failbit); }
710
catch(std::ios_base::failure&) {}
711
throw; // rethrow original exception
714
is.setstate(std::ios_base::failbit);
723
template <class CharT, class TraitsT>
724
inline std::basic_ostream<CharT, TraitsT>&
725
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::first_day_of_the_week_before& fdb) {
726
boost::io::ios_flags_saver iflags(os);
727
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
728
std::ostreambuf_iterator<CharT> output_itr(os);
729
if (std::has_facet<custom_date_facet>(os.getloc())) {
730
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), fdb);
733
custom_date_facet* f = new custom_date_facet();
734
std::locale l = std::locale(os.getloc(), f);
736
f->put(output_itr, os, os.fill(), fdb);
741
//! input operator for first_day_of_the_week_before
742
template <class CharT, class Traits>
744
std::basic_istream<CharT, Traits>&
745
operator>>(std::basic_istream<CharT, Traits>& is,
746
first_day_of_the_week_before& fkb)
748
boost::io::ios_flags_saver iflags(is);
749
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
752
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
754
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
755
if(std::has_facet<date_input_facet>(is.getloc())) {
756
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fkb);
759
date_input_facet* f = new date_input_facet();
760
std::locale l = std::locale(is.getloc(), f);
762
f->get(sit, str_end, is, fkb);
766
std::ios_base::iostate exception_mask = is.exceptions();
767
if(std::ios_base::failbit & exception_mask) {
768
try { is.setstate(std::ios_base::failbit); }
769
catch(std::ios_base::failure&) {}
770
throw; // rethrow original exception
773
is.setstate(std::ios_base::failbit);
784
#endif // DATE_TIME_GREGORIAN_IO_HPP__