ITCHCPP 1.6.0
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
time.hpp
Go to the documentation of this file.
1#pragma once
2
12
13#include <chrono>
14#include <cstdint>
15#include <format>
16#include <string>
17
18namespace itch {
19
21using ItchTimePoint = std::chrono::sys_time<std::chrono::nanoseconds>;
22
34[[nodiscard]] constexpr auto to_time_point(
35 std::chrono::year_month_day session_date, std::uint64_t nanos_past_midnight
36) noexcept -> ItchTimePoint {
37 return std::chrono::sys_days {session_date} + std::chrono::nanoseconds {nanos_past_midnight};
38}
39
44[[nodiscard]] inline auto format_timestamp(std::uint64_t nanos_past_midnight) -> std::string {
45 const std::chrono::hh_mm_ss time_of_day {std::chrono::nanoseconds {nanos_past_midnight}};
46 return std::format("{:%T}", time_of_day);
47}
48
54[[nodiscard]] inline auto format_time_point(
55 std::chrono::year_month_day session_date, std::uint64_t nanos_past_midnight
56) -> std::string {
57 return std::format("{:%F %T}", to_time_point(session_date, nanos_past_midnight));
58}
59
60} // namespace itch
auto format_time_point(std::chrono::year_month_day session_date, std::uint64_t nanos_past_midnight) -> std::string
Formats a session date plus an ITCH timestamp as a full date-time.
Definition time.hpp:54
auto format_timestamp(std::uint64_t nanos_past_midnight) -> std::string
Formats a raw ITCH timestamp as a time-of-day string.
Definition time.hpp:44
constexpr auto to_time_point(std::chrono::year_month_day session_date, std::uint64_t nanos_past_midnight) noexcept -> ItchTimePoint
Combines a session date with an ITCH timestamp into a time point.
Definition time.hpp:34
std::chrono::sys_time< std::chrono::nanoseconds > ItchTimePoint
A system-clock time point at nanosecond resolution.
Definition time.hpp:21