forked from ars3niy/tdlib-purple
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.cpp
More file actions
27 lines (22 loc) · 741 Bytes
/
Copy pathformat.cpp
File metadata and controls
27 lines (22 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "format.h"
#include <fmt/format.h>
std::string formatMessage(const char *fmt, std::initializer_list<std::string> args)
{
fmt::dynamic_format_arg_store<fmt::format_context> fa;
for (const std::string &arg: args)
fa.push_back(arg);
return fmt::vformat(fmt, fa);
}
std::string formatMessage(const char *fmt, const std::string &s)
{
return formatMessage(fmt, {s});
}
std::string formatDuration(int32_t seconds)
{
int32_t hours = seconds / 3600;
seconds -= hours * 3600;
int32_t minutes = seconds / 60;
seconds -= minutes * 60;
// TRANSLATOR: Time format. For HH:MM:SS use "{:02}:{:02}:{:02}" without the quotes.
return fmt::format(_("{:02}:{:02}:{:02}"), hours, minutes, seconds);
}