+QString format_time_minutes(const Timestamp& t, signed precision, bool sign)
+{
+ const Timestamp whole_seconds = floor(abs(t));
+ const Timestamp days = floor(whole_seconds / (60 * 60 * 24));
+ const unsigned int hours = fmod(whole_seconds / (60 * 60), 24).convert_to<uint>();
+ const unsigned int minutes = fmod(whole_seconds / 60, 60).convert_to<uint>();
+ const unsigned int seconds = fmod(whole_seconds, 60).convert_to<uint>();
+
+ QString s;
+ QTextStream ts(&s);
+
+ if (t < 0)
+ ts << "-";
+ else if (sign)
+ ts << "+";
+
+ bool use_padding = false;
+
+ // DD
+ if (days) {
+ ts << days.str().c_str() << ":";
+ use_padding = true;
+ }
+
+ // HH
+ if (hours || days) {
+ ts << pad_number(hours, use_padding ? 2 : 0) << ":";
+ use_padding = true;
+ }
+
+ // MM
+ ts << pad_number(minutes, use_padding ? 2 : 0);
+
+ ts << ":";
+
+ // SS
+ ts << pad_number(seconds, 2);
+
+ if (precision) {
+ ts << ".";
+
+ const Timestamp fraction = fabs(t) - whole_seconds;
+
+ ostringstream ss;
+ ss << fixed << setprecision(precision) << setfill('0') << fraction;
+ string fs = ss.str();
+
+ // Copy all digits, inserting spaces as unit separators
+ for (int i = 1; i <= precision; i++) {
+ // Start at index 2 to skip the "0." at the beginning
+ ts << fs.at(1 + i);
+
+ if ((i > 0) && (i % 3 == 0) && (i != precision))
+ ts << " ";
+ }
+ }
+
+ return s;
+}
+
+/**
+ * Split a string into tokens at occurences of the separator.
+ *
+ * @param[in] text The input string to split.
+ * @param[in] separator The delimiter between tokens.
+ *
+ * @return A vector of broken down tokens.
+ */
+vector<string> split_string(string text, string separator)
+{
+ vector<string> result;
+ size_t pos;
+
+ while ((pos = text.find(separator)) != std::string::npos) {
+ result.push_back(text.substr(0, pos));
+ text = text.substr(pos + separator.length());
+ }
+ result.push_back(text);
+
+ return result;
+}
+
+/**
+ * Return the width of a string in a given font.
+ *
+ * @param[in] metric metrics of the font
+ * @param[in] string the string whose width should be determined
+ *
+ * @return width of the string in pixels
+ */
+std::streamsize text_width(const QFontMetrics &metric, const QString &string)