27 using boost::chrono::time_point_cast;
42 time::system_clock::time_point())
48 : m_notBefore(toTimePointCeil(notBefore))
49 , m_notAfter(toTimePointFloor(notAfter))
58 template<encoding::Tag TAG>
62 size_t totalLength = 0;
67 totalLength += encoder.prependVarNumber(totalLength);
86 m_wire = buffer.block();
96 NDN_THROW(
Error(
"The supplied block does not contain wire format"));
119 catch (
const std::bad_cast&) {
120 NDN_THROW(
Error(
"Invalid date format in NOT-BEFORE or NOT-AFTER field"));
124 ValidityPeriod::TimePoint
127 return TimePoint(boost::chrono::floor<TimePoint::duration>(t.time_since_epoch()));
130 ValidityPeriod::TimePoint
133 return TimePoint(boost::chrono::ceil<TimePoint::duration>(t.time_since_epoch()));
136 ValidityPeriod::TimePoint
137 ValidityPeriod::decodeTimePoint(
const Block& element)
140 static const auto minTime = toTimePointCeil(time::system_clock::time_point::min());
141 static const auto maxTime = toTimePointFloor(time::system_clock::time_point::max());
150 if (value < minValue) {
153 if (value > maxValue) {
164 m_notBefore = toTimePointCeil(notBefore);
165 m_notAfter = toTimePointFloor(notAfter);
169 std::pair<time::system_clock::time_point, time::system_clock::time_point>
172 return {m_notBefore, m_notAfter};
178 return m_notBefore <= now && now <= m_notAfter;
Represents a TLV element of the NDN packet format.
size_t elements_size() const noexcept
Equivalent to elements().size().
const element_container & elements() const noexcept
Get container of sub-elements.
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
uint32_t type() const noexcept
Return the TLV-TYPE of the Block.
void reset() noexcept
Reset the Block to a default-constructed state.
void parse() const
Parse TLV-VALUE into sub-elements.
Represents a ValidityPeriod TLV element.
ValidityPeriod()
Create a validity period that is invalid for any timepoint.
static ValidityPeriod makeRelative(time::seconds validFrom, time::seconds validUntil, const time::system_clock::time_point &now=time::system_clock::now())
Construct ValidityPeriod relative to a timepoint.
std::pair< time::system_clock::time_point, time::system_clock::time_point > getPeriod() const
Get the stored validity period.
bool isValid(const time::system_clock::time_point &now=time::system_clock::now()) const
Check if now falls within the validity period.
void wireDecode(const Block &wire)
Decode ValidityPeriod from TLV block.
ValidityPeriod & setPeriod(const time::system_clock::time_point ¬Before, const time::system_clock::time_point ¬After)
Set validity period [notBefore, notAfter].
const Block & wireEncode() const
Encode ValidityPeriod into TLV block.
::boost::chrono::time_point< system_clock > time_point
#define NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
EncodingImpl< EstimatorTag > EncodingEstimator
size_t prependStringBlock(EncodingImpl< TAG > &encoder, uint32_t type, std::string_view value)
Prepend a TLV element containing a string.
std::string readString(const Block &block)
Read the TLV-VALUE of a TLV element as a string.
EncodingImpl< EncoderTag > EncodingBuffer
Contains the ndn-cxx security framework.
std::ostream & operator<<(std::ostream &os, const AdditionalDescription &desc)
constexpr size_t NOT_AFTER_OFFSET
constexpr size_t ISO_DATETIME_SIZE
constexpr size_t NOT_BEFORE_OFFSET
::boost::chrono::seconds seconds
std::string toIsoString(const system_clock::time_point &timePoint)
Convert to the ISO 8601 string representation, basic format (YYYYMMDDTHHMMSS,fffffffff).
system_clock::time_point fromIsoString(const std::string &isoString)
Convert from the ISO 8601 basic string format (YYYYMMDDTHHMMSS,fffffffff) to the internal time format...