ptth/bare_minimum_crypto/cpp/time_helpers.h

30 lines
569 B
C++

#pragma once
#include <stdint.h>
namespace BareMinimumCrypto {
const int64_t about_1_week = (int64_t)7 * 86400;
const int64_t about_3_months = (int64_t)105 * 86400;
const int64_t about_1_year = (int64_t)365 * 86400;
struct Instant {
// Seconds since Unix epoch
int64_t x;
Instant (int64_t x);
static Instant now ();
};
struct TimeRange {
int64_t not_before;
int64_t not_after;
bool contains (Instant x) const;
int64_t duration () const;
static TimeRange from_start_and_dur (Instant start, int64_t dur);
};
int test_time ();
}