OutItrT put(OutItrT next, std::ios_base& a_ios, char_type fill_char, const date_type& d) const { if (d.is_special()) { return do_put_special(next, a_ios, fill_char, d.as_special()); } //The following line of code required the date to support a to_tm function return do_put_tm(next, a_ios, fill_char, to_tm(d), m_format); }
static time_rep_type get_time_rep(const date_type& day, const time_duration_type& tod, date_time::dst_flags /* dst */ = not_dst) { if(day.is_special() || tod.is_special()) { if(day.is_not_a_date() || tod.is_not_a_date_time()) { return time_rep_type(date_type(not_a_date_time), time_duration_type(not_a_date_time)); } else if(day.is_pos_infinity()) { if(tod.is_neg_infinity()) { return time_rep_type(date_type(not_a_date_time), time_duration_type(not_a_date_time)); } else { return time_rep_type(day, time_duration_type(pos_infin)); } } else if(day.is_neg_infinity()) { if(tod.is_pos_infinity()) { return time_rep_type(date_type(not_a_date_time), time_duration_type(not_a_date_time)); } else { return time_rep_type(day, time_duration_type(neg_infin)); } } else if(tod.is_pos_infinity()) { if(day.is_neg_infinity()) { return time_rep_type(date_type(not_a_date_time), time_duration_type(not_a_date_time)); } else { return time_rep_type(date_type(pos_infin), tod); } } else if(tod.is_neg_infinity()) { if(day.is_pos_infinity()) { return time_rep_type(date_type(not_a_date_time), time_duration_type(not_a_date_time)); } else { return time_rep_type(date_type(neg_infin), tod); } } } return time_rep_type(day, tod); }
duration_type operator-(const date_type& d) const { if (!this->is_special() && !d.is_special()) { // The duration underlying type may be wider than the date underlying type. // Thus we calculate the difference in terms of two durations from some common fixed base date. typedef typename duration_type::duration_rep_type duration_rep_type; return duration_type(static_cast< duration_rep_type >(days_) - static_cast< duration_rep_type >(d.days_)); } else { // In this case the difference will be a special value, too date_rep_type val = date_rep_type(days_) - date_rep_type(d.days_); return duration_type(val.as_special()); } }