+enum class TimeUnit {
+ Time = 1,
+ Samples = 2
+};
+
+enum class SIPrefix {
+ unspecified = -1,
+ yocto, zepto,
+ atto, femto, pico,
+ nano, micro, milli,
+ none,
+ kilo, mega, giga,
+ tera, peta, exa,
+ zetta, yotta
+};
+
+/// Returns the exponent that corresponds to a given prefix.
+int exponent(SIPrefix prefix);
+
+/// Timestamp type providing yoctosecond resolution.
+typedef boost::multiprecision::number<
+ boost::multiprecision::cpp_dec_float<24>,
+ boost::multiprecision::et_off> Timestamp;
+
+/**
+ * Formats a given timestamp with the specified SI prefix.
+ *
+ * If 'prefix' is left 'unspecified', the function chooses a prefix so that
+ * the value in front of the decimal point is between 1 and 999.
+ *
+ * The default value "s" for the unit argument makes the most sense when
+ * formatting time values, but a different value can be given if the function
+ * is reused to format a value of another quantity.
+ *
+ * @param t The value to format.
+ * @param prefix The SI prefix to use.
+ * @param precision The number of digits after the decimal separator.
+ * @param unit The unit of quantity.
+ * @param sign Whether or not to add a sign also for positive numbers.
+ *
+ * @return The formated value.
+ */
+QString format_time_si(
+ const Timestamp& t,
+ SIPrefix prefix = SIPrefix::unspecified,
+ unsigned precision = 0,
+ QString unit = "s",
+ bool sign = true);