flatten 20260225
This commit is contained in:
59
tjp/core/time/Time.hpp
Normal file
59
tjp/core/time/Time.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
// 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"
|
||||
Reference in New Issue
Block a user