std::string_view 的使用
This commit is contained in:
@@ -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("时间格式错误");
|
||||
|
||||
Reference in New Issue
Block a user