18#include "matpack_data.h"
22using TimeStep = std::chrono::duration<Numeric>;
26 std::chrono::system_clock::time_point
time;
30 [[nodiscard]] Index
Version() const noexcept {
return 1; }
34 explicit Time(std::time_t t)
35 :
time(
std::chrono::system_clock::from_time_t(t)) {}
40 [[nodiscard]] std::time_t
toTimeT()
const {
41 return std::chrono::system_clock::to_time_t(
time);
46 tm* z = localtime_r(&x, &y);
53 tm* z = gmtime_r(&x, &y);
59 return TimeStep(x.tm_hour * 3600 + x.tm_min * 60 + x.tm_sec +
63 return time.time_since_epoch();
84 template <
typename T,
typename R>
86 time += std::chrono::duration_cast<InternalTimeStep>(dt);
89 template <
typename T,
typename R>
91 time -= std::chrono::duration_cast<InternalTimeStep>(dt);
94 template <
typename T,
typename R>
96 return (
Time(*
this) += dt);
98 template <
typename T,
typename R>
100 return (
Time(*
this) -= dt);
105 return std::chrono::duration_cast<TimeStep>(
time.time_since_epoch())
110 return std::fmod(
Seconds(), 1.0);
114 explicit operator Numeric()
const {
return Seconds(); }
214 std::cerr <<
msg <<
':' <<
' ' <<
Time{} -
start <<
'\n';
This file contains the definition of Array.
TimeStep median(ArrayOfTimeStep)
Returns the median time step.
ArrayOfIndex time_steps(const ArrayOfTime ×, const TimeStep &dt)
Finds the index matching demands in a list of times.
std::chrono::duration< Numeric > TimeStep
A duration of time, 1 full tick should be 1 second.
TimeStep time_stepper_selection(const String &time_step)
Returns a time step from valid string.
Vector time_vector(const ArrayOfTime ×)
Converts from each Time to seconds and returns as Vector.
Time mean_time(const ArrayOfTime &ts, Index s=0, Index e=-1)
Computes the average time in a list.
TimeStep mean(const ArrayOfTimeStep &)
Returns the mean time step.
std::ostream & operator<<(std::ostream &os, const TimeStep &dt)
Debug output for duration.
Time next_even(const Time &t, const TimeStep &dt)
Returns the next time after t with an even time-step.
This can be used to make arrays out of anything.
Helper macros for debugging.
#define ARTS_USER_ERROR_IF(condition,...)
This file contains the definition of String, the ARTS string class.
Used to debug execution time, prints msg+time on destruction to std::cerr.
DebugTime(const std::string_view s="Time")
Class to handle time in ARTS.
std::time_t toTimeT() const
InternalTimeStep EpochTime() const
Numeric PartOfSecond() const
Time operator-(const std::chrono::duration< T, R > &dt) const
bool operator<(const Time &t) const noexcept
decltype(time)::duration InternalTimeStep
std::chrono::system_clock::time_point time
bool operator==(const Time &t) const noexcept
TimeStep seconds_into_day() const
Time & operator+=(const std::chrono::duration< T, R > &dt)
InternalTimeStep operator-(const Time &t) const noexcept
bool operator!=(const Time &t) const noexcept
bool operator>=(const Time &t) const noexcept
Index Version() const noexcept
bool operator<=(const Time &t) const noexcept
friend std::istream & operator>>(std::istream &is, Time &t)
friend std::ostream & operator<<(std::ostream &os, const Time &t)
Time & operator-=(const std::chrono::duration< T, R > &dt)
Time operator+(const std::chrono::duration< T, R > &dt) const
bool operator>(const Time &t) const noexcept
std::tm toGMTStruct() const