12 auto now = std::chrono::system_clock::now();
13 return std::chrono::duration_cast<std::chrono::seconds>(
now.time_since_epoch()).count();
18 return ::VoltMod::ParseDuration(
duration);
31 return std::format(
"{} week{}",
w,
w > 1 ?
"s" :
"");
36 return std::format(
"{} day{}",
d,
d > 1 ?
"s" :
"");
41 return std::format(
"{} hour{}",
h,
h > 1 ?
"s" :
"");
43 if (
seconds % SecondsPerMinute == 0 &&
seconds >= SecondsPerMinute)
46 return std::format(
"{} minute{}",
m,
m > 1 ?
"s" :
"");
48 return std::format(
"{} second{}",
seconds,
seconds > 1 ?
"s" :
"");
55 return units.Permanent;
61 const std::string* Label;
64 {SecondsPerDay, &
units.Days},
65 {SecondsPerHour, &
units.Hours},
66 {SecondsPerMinute, &
units.Minutes},
109 return std::format(
"{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}",
tm.tm_year + 1900,
tm.tm_mon + 1,
tm.tm_mday,
110 tm.tm_hour,
tm.tm_min,
tm.tm_sec);
static std::string FormatDurationLabel(int64_t seconds, const DurationUnitLabels &units)
static int64_t ParseDuration(const std::string &duration)
static bool IsExpired(int64_t expiresAt)
static std::string FormatDuration(int64_t seconds)
static std::string FormatExpiry(int64_t expiresAt, int64_t nowSec, std::string_view permanentText, std::string_view expiresInPrefix)
static int64_t GetExpirationTime(int64_t durationSeconds)
static std::string FormatTimestamp(int64_t timestamp)
static std::string ReadFile(const std::filesystem::path &path)