std::string_view 的使用

This commit is contained in:
2026-06-29 09:40:55 +08:00
parent cd446b7ca8
commit 8daf67aa5d
52 changed files with 1420 additions and 1367 deletions
+3 -2
View File
@@ -3,10 +3,11 @@
#include "Global.h"
#include <fstream>
#include <string_view>
time_t datetime_to_timestamp(const std::string &datetime) {
time_t datetime_to_timestamp(std::string_view datetime) {
std::tm tm = {};
std::istringstream ss(datetime);
std::istringstream ss{std::string(datetime)};
ss >> std::get_time(&tm, "%Y-%m-%d %H:%M:%S");
if (ss.fail()) {
throw std::runtime_error("时间格式错误");