
#ifndef BASE_FORMAT_H
#define BASE_FORMAT_H
#include <cstring>
#include <iomanip>
#include <iostream>
#include <string>
#include <bitset>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <array>
#include <cmath>
#include <stdexcept>
#include <string>
#include <numeric>
#include <unordered_map>
#include <map>
#include <chrono>
#include <functional>
#include "Bit.h"
#include "Json.h"
#include "magic_enum/export.h"


// 1纳秒是 10 -9次方秒
struct MLAT_timestamp {
    explicit MLAT_timestamp();
    explicit MLAT_timestamp(const std::string& 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]] Json toJson() const {
        Json ret = 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();
};

#endif
