| 142 | // strings -------------------------------------------------------- |
| 143 | |
| 144 | UArray *Duration_asUArrayWithFormat_(const Duration *self, const char *format) { |
| 145 | DurationComponents c = Duration_asComponents(self); |
| 146 | char s[128]; |
| 147 | UArray *ba = |
| 148 | UArray_newWithCString_(format ? format : "%Y years %d days %H:%M:%S"); |
| 149 | |
| 150 | snprintf(s, 128, "%i", (int)c.years); |
| 151 | UArray_replaceCString_withCString_(ba, "%Y", s); |
| 152 | |
| 153 | snprintf(s, 128, "%04i", (int)c.years); |
| 154 | UArray_replaceCString_withCString_(ba, "%y", s); |
| 155 | |
| 156 | snprintf(s, 128, "%02i", (int)c.days); |
| 157 | UArray_replaceCString_withCString_(ba, "%d", s); |
| 158 | |
| 159 | snprintf(s, 128, "%02i", (int)c.hours); |
| 160 | UArray_replaceCString_withCString_(ba, "%H", s); |
| 161 | |
| 162 | snprintf(s, 128, "%02i", (int)c.minutes); |
| 163 | UArray_replaceCString_withCString_(ba, "%M", s); |
| 164 | |
| 165 | snprintf(s, 128, "%02f", c.seconds); |
| 166 | UArray_replaceCString_withCString_(ba, "%S", s); |
| 167 | |
| 168 | return ba; |
| 169 | } |
| 170 | |
| 171 | void Duration_print(const Duration *self) { |
| 172 | UArray *ba = Duration_asUArrayWithFormat_(self, NULL); |
no test coverage detected