Files
core_zero/tjp/core/time/Time.hpp
Timothy Prepscius 996151a56a flatten 20260225
2026-02-25 12:43:06 -05:00

60 lines
1.1 KiB
C++

// License: Modified MIT (NON-AI)
// See the LICENSE file in the root directory for license information.
// Copyright 2025 Timothy Prepscius
#pragma once
#include "Time.h"
#include <limits>
namespace tjp::core::time {
using V = s64;
struct Rate {
Amount v;
static const Amount Zero;
} ;
struct Duration {
V v;
static const Duration Zero;
} ;
constexpr Duration Forever { V(60) * 60 * 24 * 365 * 100 };
constexpr Duration Now { 0 };
struct Time {
V v;
static const Time Zero;
} ;
struct Converter {
V v;
constexpr Duration operator()(Amount a) const {
return { V(a * v) };
}
} ;
constexpr Converter Milliseconds { 1 };
constexpr Converter Centiseconds { 10 };
constexpr Converter Deciseconds { 100 };
constexpr Converter Seconds { 1000 };
constexpr Converter Minutes { 60 * 1000 };
constexpr Converter Hours { 60 * 60 * 1000 };
constexpr Converter Days { 24 * 60 * 60 * 1000 };
constexpr Converter Years { V(365) * 24 * 60 * 60 * 1000 };
constexpr Time FarFuture { std::numeric_limits<V>::max() };
constexpr Time Epoch { 0 };
}
#include "Time+operations.hpp"