mirror of
https://github.com/aristocratos/btop.git
synced 2024-06-26 18:10:32 +12:00
Make strf_time take a string_view as format string
This commit is contained in:
parent
a9061dfad2
commit
c60bd928d4
|
@ -295,7 +295,7 @@ namespace Draw {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool update_clock(bool force) {
|
bool update_clock(bool force) {
|
||||||
const auto& clock_format = Config::getS("clock_format");
|
const std::string_view clock_format = Config::getS("clock_format");
|
||||||
if (not Cpu::shown or clock_format.empty()) {
|
if (not Cpu::shown or clock_format.empty()) {
|
||||||
if (clock_format.empty() and not Global::clock.empty()) Global::clock.clear();
|
if (clock_format.empty() and not Global::clock.empty()) Global::clock.clear();
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -27,10 +27,10 @@ namespace Logger {
|
||||||
using namespace Tools;
|
using namespace Tools;
|
||||||
std::mutex log_mtx{};
|
std::mutex log_mtx{};
|
||||||
bool first = true;
|
bool first = true;
|
||||||
const string tdf = "%Y/%m/%d (%T) | ";
|
|
||||||
|
|
||||||
size_t loglevel;
|
size_t loglevel;
|
||||||
fs::path logfile;
|
fs::path logfile;
|
||||||
|
constexpr const std::string_view tdf = "%Y/%m/%d (%T) | ";
|
||||||
|
|
||||||
//* Wrapper for lowering priviliges if using SUID bit and currently isn't using real userid
|
//* Wrapper for lowering priviliges if using SUID bit and currently isn't using real userid
|
||||||
class lose_priv {
|
class lose_priv {
|
||||||
|
|
|
@ -18,13 +18,15 @@ tab-size = 4
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <sstream>
|
#include <fstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <utility>
|
#include <iostream>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
@ -485,11 +487,11 @@ namespace Tools {
|
||||||
return new_str;
|
return new_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
string strf_time(const string& strf) {
|
string strf_time(const std::string_view strf) {
|
||||||
auto in_time_t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
auto in_time_t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
||||||
std::tm bt {};
|
std::tm bt {};
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::put_time(localtime_r(&in_time_t, &bt), strf.c_str());
|
ss << std::put_time(localtime_r(&in_time_t, &bt), strf.data());
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ tab-size = 4
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -303,7 +304,7 @@ namespace Tools {
|
||||||
std::string operator*(const string& str, int64_t n);
|
std::string operator*(const string& str, int64_t n);
|
||||||
|
|
||||||
//* Return current time in <strf> format
|
//* Return current time in <strf> format
|
||||||
string strf_time(const string& strf);
|
string strf_time(const std::string_view strf);
|
||||||
|
|
||||||
string hostname();
|
string hostname();
|
||||||
string username();
|
string username();
|
||||||
|
|
Loading…
Reference in a new issue