Files
SSR/SSR/convert/base_format.h
T
2026-08-05 14:37:55 +08:00

43 lines
1.5 KiB
C++

#pragma once
#include <cstring>
#include <string_view>
#include "Psc_Cpp_Core/Base/JSON.h"
#include "SSR/global.h"
namespace SSR {
// 1纳秒是 10 -9次方秒
struct MLAT_timestamp {
explicit MLAT_timestamp();
explicit MLAT_timestamp(std::string_view memory_6);
MLAT_timestamp(std::uint32_t daysec, std::uint32_t nanosec);
std::uint32_t daysec{}; // 当天的秒数 高18位
std::uint32_t nanosec{}; // 当天的纳秒数 低30位
std::string to_bin_string() const;
std::string to_memory() const;
unsigned long hh{};
unsigned long mm{};
unsigned long ss{};
std::string memory{};
bool operator<(const MLAT_timestamp& other) const {
// 比较 daysec(高18位)
if (daysec != other.daysec) {
return daysec < other.daysec;
}
// 如果 daysec 相等,比较 nanosec(低30位)
return nanosec < other.nanosec;
}
[[nodiscard]] Psc::JSON toJson() const {
Psc::JSON ret = Psc::JSON::object();
ret.append({"", daysec});
ret.append({"纳秒", nanosec});
ret.append({"时间", std::to_string(hh) + ":" + std::to_string(mm) + ":" + std::to_string(ss)});
return ret;
}
[[nodiscard]] std::string to_string() const {
return "{" + std::to_string(daysec) + "," + std::to_string(nanosec) + "}_" + "[" + std::to_string(hh) +
"时:" + std::to_string(mm) + "分:" + std::to_string(ss) +
""
"]";
}
void parse_hhmmss();
};
}