Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
TimeUtils.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2024, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include <xrpl/basics/chrono.h>
23
24#include <chrono>
25#include <optional>
26#include <string>
27
28namespace util {
29
36[[nodiscard]] std::optional<std::chrono::system_clock::time_point>
37systemTpFromUtcStr(std::string const& dateStr, std::string const& format);
38
46[[nodiscard]] std::string
47systemTpToUtcStr(std::chrono::system_clock::time_point const& tp, std::string const& format);
48
54[[nodiscard]] std::chrono::system_clock::time_point
55systemTpFromLedgerCloseTime(ripple::NetClock::time_point closeTime);
56
57} // namespace util
This namespace contains various utilities.
Definition AccountUtils.hpp:30
std::chrono::system_clock::time_point systemTpFromLedgerCloseTime(ripple::NetClock::time_point closeTime)
Convert a ledger close time which is XRPL network clock to a system_clock::time_point.
Definition TimeUtils.cpp:51
std::string systemTpToUtcStr(std::chrono::system_clock::time_point const &tp, std::string const &format)
Converts a system_clock time_point to a formatted UTC string.
Definition TimeUtils.cpp:44
std::optional< std::chrono::system_clock::time_point > systemTpFromUtcStr(std::string const &dateStr, std::string const &format)
Convert a UTC date string to a system_clock::time_point if possible.
Definition TimeUtils.cpp:33