OutItrT put_nth_kday(OutItrT next, std::ios_base& a_ios, CharT a_fill, const nth_kday_type& nkd, const facet_type& facet) const { put_string(next, phrase_strings[nkd.nth_week() -1]); next = a_fill; //TODO change this ??? facet.put(next, a_ios, a_fill, nkd.day_of_week()); next = a_fill; //TODO change this ??? put_string(next, string_type(of_string)); next = a_fill; //TODO change this ??? facet.put(next, a_ios, a_fill, nkd.month()); return next; }
nth_kday_type get_nth_kday_type(stream_itr_type& sitr, stream_itr_type& stream_end, std::ios_base& a_ios, const facet_type& facet) const { // skip leading whitespace while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; } typename nth_kday_type::week_num wn; day_of_week_type wd(0); // no default constructor month_type m(1); // no default constructor match_results mr = m_element_strings.match(sitr, stream_end); switch(mr.current_match) { case first : { wn = nth_kday_type::first; break; } case second : { wn = nth_kday_type::second; break; } case third : { wn = nth_kday_type::third; break; } case fourth : { wn = nth_kday_type::fourth; break; } case fifth : { wn = nth_kday_type::fifth; break; } default: { boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'")); BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(wn = nth_kday_type::first); } } // week num facet.get(sitr, stream_end, a_ios, wd); // day_of_week extract_element(sitr, stream_end, of); // "of" element facet.get(sitr, stream_end, a_ios, m); // month return nth_kday_type(wn, wd, m); }
//! Formats a month as as string into an output iterator static void format_weekday(const weekday_type& wd, ostream_type& os, const facet_type& f, bool as_long_string) { std::ostreambuf_iterator<charT> oitr(os); if (as_long_string) { f.put_weekday_long(oitr, wd.as_enum()); } else { f.put_weekday_short(oitr, wd.as_enum()); } } // format_weekday
OutItrT put_period(OutItrT next, std::ios_base& a_ios, char_type a_fill, const period_type& p, const facet_type& facet) const { put_period_start_delimeter(next); next = facet.put(next, a_ios, a_fill, p.begin()); put_period_separator(next); if (m_range_option == AS_CLOSED_RANGE) { facet.put(next, a_ios, a_fill, p.last()); } else { facet.put(next, a_ios, a_fill, p.end()); } put_period_end_delimeter(next); return next; }
OutItrT put_kday_after(OutItrT next, std::ios_base& a_ios, CharT a_fill, const kday_after_type& fka, const facet_type& facet) const { facet.put(next, a_ios, a_fill, fka.day_of_week()); next = a_fill; //TODO change this ??? put_string(next, phrase_strings[after]); return next; }
last_kday_type get_last_kday_type(stream_itr_type& sitr, stream_itr_type& stream_end, std::ios_base& a_ios, const facet_type& facet) const { // skip leading whitespace while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; } day_of_week_type wd(0); // no default constructor month_type m(1); // no default constructor extract_element(sitr, stream_end, last); // "last" element facet.get(sitr, stream_end, a_ios, wd); // day_of_week extract_element(sitr, stream_end, of); // "of" element facet.get(sitr, stream_end, a_ios, m); // month return last_kday_type(wd, m); }
//! Put date into an ostream static void date_put(const date_type& d, ostream_type& os, const facet_type& f) { special_values sv = d.as_special(); if (sv == not_special) { ymd_type ymd = d.year_month_day(); ostream_ymd_formatter<ymd_type, facet_type, charT>::ymd_put(ymd, os, f); } else { // output a special value std::ostreambuf_iterator<charT> coi(os); f.put_special_value(coi, sv); } }
kday_after_type get_kday_after_type(stream_itr_type& sitr, stream_itr_type& stream_end, std::ios_base& a_ios, const facet_type& facet) const { // skip leading whitespace while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; } day_of_week_type wd(0); // no default constructor facet.get(sitr, stream_end, a_ios, wd); // day_of_week extract_element(sitr, stream_end, after); // "after" element return kday_after_type(wd); }
partial_date_type get_partial_date_type(stream_itr_type& sitr, stream_itr_type& stream_end, std::ios_base& a_ios, const facet_type& facet) const { // skip leading whitespace while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; } day_type d(1); month_type m(1); facet.get(sitr, stream_end, a_ios, d); facet.get(sitr, stream_end, a_ios, m); return partial_date_type(d,m); }
// Put ymd to ostream -- part of ostream refactor static void ymd_put(ymd_type ymd, ostream_type& os, const facet_type& f) { std::ostreambuf_iterator<charT> oitr(os); charT fill_char = '0'; switch (f.date_order()) { case ymd_order_iso: { os << ymd.year; if (f.has_date_sep_chars()) { f.month_sep_char(oitr); } month_formatter_type::format_month(ymd.month, os, f); if (f.has_date_sep_chars()) { f.day_sep_char(oitr); } os << std::setw(2) << std::setfill(fill_char) << ymd.day; break; } case ymd_order_us: { month_formatter_type::format_month(ymd.month, os, f); if (f.has_date_sep_chars()) { f.day_sep_char(oitr); } os << std::setw(2) << std::setfill(fill_char) << ymd.day; if (f.has_date_sep_chars()) { f.month_sep_char(oitr); } os << ymd.year; break; } case ymd_order_dmy: { os << std::setw(2) << std::setfill(fill_char) << ymd.day; if (f.has_date_sep_chars()) { f.day_sep_char(oitr); } month_formatter_type::format_month(ymd.month, os, f); if (f.has_date_sep_chars()) { f.month_sep_char(oitr); } os << ymd.year; break; } } }