diff src/core/time.cc @ 369:47c9f8502269

*: clang-format all the things I've edited the formatting a bit. Now pointer asterisks (and reference ampersands) are on the variable instead of the type, as well as having newlines for function braces (but nothing else)
author Paper <paper@tflc.us>
date Fri, 25 Jul 2025 10:16:02 -0400
parents d928ec7b6a0d
children
line wrap: on
line diff
--- a/src/core/time.cc	Fri Jul 25 10:05:23 2025 -0400
+++ b/src/core/time.cc	Fri Jul 25 10:16:02 2025 -0400
@@ -11,22 +11,26 @@
 
 namespace Time {
 
-static Timestamp GetSecondsInMinutes(Timestamp length) {
+static Timestamp GetSecondsInMinutes(Timestamp length)
+{
 	return std::llround(static_cast<double>(length) / 60.0);
 }
 
-static Timestamp GetSecondsInHours(Timestamp length) {
+static Timestamp GetSecondsInHours(Timestamp length)
+{
 	return std::llround(static_cast<double>(length) / 3600.0);
 }
 
-static Timestamp GetSecondsInDays(Timestamp length) {
+static Timestamp GetSecondsInDays(Timestamp length)
+{
 	return std::llround(static_cast<double>(length) / 86400.0);
 }
 
-std::string GetSecondsAsRelativeString(Timestamp length) {
+std::string GetSecondsAsRelativeString(Timestamp length)
+{
 	std::string result;
 
-	auto get = [](Timestamp val, const std::string& s, const std::string& p) {
+	auto get = [](Timestamp val, const std::string &s, const std::string &p) {
 		return Strings::ToUtf8String(val) + " " + (val == 1 ? s : p);
 	};
 
@@ -53,7 +57,8 @@
 
 /* "amount" does not have to be in seconds, and can be any unit if the correct ratio to seconds
  * is passed to "unit_in_seconds" (for example, if the input is minutes, pass 60.0) */
-std::string GetSecondsAsAbsoluteString(Units unit_cutoff, Timestamp amount, double unit_in_seconds) {
+std::string GetSecondsAsAbsoluteString(Units unit_cutoff, Timestamp amount, double unit_in_seconds)
+{
 	/* avoid calculating this twice */
 	const double years_conv = (31556952.0 / unit_in_seconds);
 	const double months_conv = (2629746.0 / unit_in_seconds);
@@ -69,8 +74,8 @@
 	const int minutes = std::fmod(amount, hours_conv) / minutes_conv;
 	const int seconds = std::fmod(amount, minutes_conv) / seconds_conv;
 
-	const auto add_time_segment = [](std::ostringstream& str, int64_t amount, const std::string_view& singular,
-	                                 const std::string_view& plural, bool always = false) {
+	const auto add_time_segment = [](std::ostringstream &str, int64_t amount, const std::string_view &singular,
+	                                 const std::string_view &plural, bool always = false) {
 		if (amount > 0 || always)
 			str << amount << ((amount == 1) ? singular : plural);
 	};
@@ -94,11 +99,13 @@
 	return string.str();
 }
 
-Timestamp GetSystemTime() {
+Timestamp GetSystemTime()
+{
 	return QDateTime::currentDateTime().toUTC().toSecsSinceEpoch();
 }
 
-Timestamp ParseISO8601Time(const std::string& str) {
+Timestamp ParseISO8601Time(const std::string &str)
+{
 	return QDateTime::fromString(Strings::ToQString(str), Qt::ISODateWithMs).toUTC().toSecsSinceEpoch();
 }