Files
MicrOBU/microbu-esp32c5/external/vanetza-idf/tools/pki/time.hpp
T
Ashin Walpola 0e9525162d Keep the colleague's microbu-esp32c5 tree in this repository
obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but
that tree was gitignored, so a clone of this repository could not build the
firmware it ships. It is now committed here as ordinary files in its own
folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP
bridge's signature verification (--trust) used on the bench. Nothing is
fetched from or pushed to the colleague's repository; this repository and
its remotes carry everything. The folder's own .gitignore keeps build output,
downloaded components and private key material out, as it did there; the
committed file set is identical to that repository's tracked files.

The ESP32-C5 is still flashed from obu-firmware/, which only takes
vanetza-idf from microbu-esp32c5/, so the two stay separate folders.
FLASHING.md says how to take a newer version of the colleague's tree (copy
it over the folder, rebuild, test, commit).
2026-09-23 17:46:40 +02:00

58 lines
1.6 KiB
C++

#pragma once
#include <vanetza/common/clock.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/optional/optional.hpp>
#include <chrono>
#include <string>
namespace vanetza
{
namespace pki
{
/**
* Get TAI offset relative to UTC for a particular time point t
* \param t offset at this time point
* \return TAI offset in seconds
*/
boost::posix_time::time_duration utc_tai_offset(boost::posix_time::ptime t);
/**
* Get current time from system clock, corrected by TAI offset
*/
Clock::time_point current_time();
/**
* Parse a human-readable duration into whole hours.
*
* Accepted form: "<N><unit>" where N is a non-negative integer and unit is
* one of:
* s — seconds (truncated to whole hours)
* m — minutes (truncated to whole hours)
* h — hours
* d — days (24 h)
* w — weeks (168 h)
*
* Returns boost::none on empty input, missing/unknown unit, negative value,
* unparseable number, or trailing garbage.
*/
boost::optional<std::chrono::hours> parse_duration_hours(const std::string&);
/**
* Parse a validity-start specification.
*
* Two accepted forms:
* - Relative: "+<N><unit>" — interpreted as `current_time() + duration`,
* where the duration follows the same grammar as parse_duration_hours().
* - Absolute (UTC): an ISO-extended date "YYYY-MM-DD" (00:00:00 implied),
* or a date+time "YYYY-MM-DDTHH:MM:SS" / "YYYY-MM-DD HH:MM:SS".
*
* Returns boost::none on empty input, malformed date, or unrecognised
* relative duration.
*/
boost::optional<Clock::time_point> parse_validity_start(const std::string&);
} // namespace pki
} // namespace vanetza