1 // file : xsd/cxx/tree/date-time-insertion.txx 2 // copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC 3 // license : GNU GPL v2 + exceptions; see accompanying LICENSE file 4 5 namespace xsd 6 { 7 namespace cxx 8 { 9 namespace tree 10 { 11 // time_zone 12 // 13 template <typename S> 14 inline ostream<S>& operator <<(ostream<S> & s,const time_zone & z)15 operator<< (ostream<S>& s, const time_zone& z) 16 { 17 return s << z.zone_hours () << z.zone_minutes (); 18 } 19 20 // gday 21 // 22 template <typename S, typename C, typename B> 23 ostream<S>& operator <<(ostream<S> & s,const gday<C,B> & x)24 operator<< (ostream<S>& s, const gday<C, B>& x) 25 { 26 bool zp (x.zone_present ()); 27 28 s << x.day () << zp; 29 30 if (zp) 31 { 32 const time_zone& z (x); 33 s << z; 34 } 35 36 return s; 37 } 38 39 // gmonth 40 // 41 template <typename S, typename C, typename B> 42 ostream<S>& operator <<(ostream<S> & s,const gmonth<C,B> & x)43 operator<< (ostream<S>& s, const gmonth<C, B>& x) 44 { 45 bool zp (x.zone_present ()); 46 47 s << x.month () << zp; 48 49 if (zp) 50 { 51 const time_zone& z (x); 52 s << z; 53 } 54 55 return s; 56 } 57 58 // gyear 59 // 60 template <typename S, typename C, typename B> 61 ostream<S>& operator <<(ostream<S> & s,const gyear<C,B> & x)62 operator<< (ostream<S>& s, const gyear<C, B>& x) 63 { 64 bool zp (x.zone_present ()); 65 66 s << x.year () << zp; 67 68 if (zp) 69 { 70 const time_zone& z (x); 71 s << z; 72 } 73 74 return s; 75 } 76 77 // gmonth_day 78 // 79 template <typename S, typename C, typename B> 80 ostream<S>& operator <<(ostream<S> & s,const gmonth_day<C,B> & x)81 operator<< (ostream<S>& s, const gmonth_day<C, B>& x) 82 { 83 bool zp (x.zone_present ()); 84 85 s << x.month () << x.day () << zp; 86 87 if (zp) 88 { 89 const time_zone& z (x); 90 s << z; 91 } 92 93 return s; 94 } 95 96 // gyear_month 97 // 98 template <typename S, typename C, typename B> 99 ostream<S>& operator <<(ostream<S> & s,const gyear_month<C,B> & x)100 operator<< (ostream<S>& s, const gyear_month<C, B>& x) 101 { 102 bool zp (x.zone_present ()); 103 104 s << x.year () << x.month () << zp; 105 106 if (zp) 107 { 108 const time_zone& z (x); 109 s << z; 110 } 111 112 return s; 113 } 114 115 // date 116 // 117 template <typename S, typename C, typename B> 118 ostream<S>& operator <<(ostream<S> & s,const date<C,B> & x)119 operator<< (ostream<S>& s, const date<C, B>& x) 120 { 121 bool zp (x.zone_present ()); 122 123 s << x.year () << x.month () << x.day () << zp; 124 125 if (zp) 126 { 127 const time_zone& z (x); 128 s << z; 129 } 130 131 return s; 132 } 133 134 // time 135 // 136 template <typename S, typename C, typename B> 137 ostream<S>& operator <<(ostream<S> & s,const time<C,B> & x)138 operator<< (ostream<S>& s, const time<C, B>& x) 139 { 140 bool zp (x.zone_present ()); 141 142 s << x.hours () << x.minutes () << x.seconds () << zp; 143 144 if (zp) 145 { 146 const time_zone& z (x); 147 s << z; 148 } 149 150 return s; 151 } 152 153 // date_time 154 // 155 template <typename S, typename C, typename B> 156 ostream<S>& operator <<(ostream<S> & s,const date_time<C,B> & x)157 operator<< (ostream<S>& s, const date_time<C, B>& x) 158 { 159 bool zp (x.zone_present ()); 160 161 s << x.year () << x.month () << x.day () 162 << x.hours () << x.minutes () << x.seconds () << zp; 163 164 if (zp) 165 { 166 const time_zone& z (x); 167 s << z; 168 } 169 170 return s; 171 } 172 173 // duration 174 // 175 template <typename S, typename C, typename B> 176 ostream<S>& operator <<(ostream<S> & s,const duration<C,B> & x)177 operator<< (ostream<S>& s, const duration<C, B>& x) 178 { 179 s << x.negative () 180 << x.years () << x.months () << x.days () 181 << x.hours () << x.minutes () << x.seconds (); 182 183 return s; 184 } 185 } 186 } 187 } 188