40using TimeStep = std::chrono::duration<Numeric>;
44 std::chrono::system_clock::time_point
time;
52 explicit Time(std::time_t t)
53 :
time(
std::chrono::system_clock::from_time_t(t)) {}
58 [[nodiscard]] std::time_t
toTimeT()
const {
64 tm* z = localtime_r(&x, &y);
71 tm* z = gmtime_r(&x, &y);
77 return TimeStep(x.tm_hour * 3600 + x.tm_min * 60 + x.tm_sec +
81 return time.time_since_epoch();
102 template <
typename T,
typename R>
104 time += std::chrono::duration_cast<InternalTimeStep>(dt);
107 template <
typename T,
typename R>
109 time -= std::chrono::duration_cast<InternalTimeStep>(dt);
112 template <
typename T,
typename R>
114 return (
Time(*
this) += dt);
116 template <
typename T,
typename R>
118 return (
Time(*
this) -= dt);
123 return std::chrono::duration_cast<TimeStep>(
time.time_since_epoch())
128 return std::fmod(
Seconds(), 1.0);
232 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,...)
std::time_t to_time_t(TimePoint time_point)
Implementation of Matrix, Vector, and such stuff.
NUMERIC Numeric
The type to use for all floating point numbers.
INDEX Index
The type to use for all integer numbers and indices.
This file contains the definition of String, the ARTS string class.
VectorView std(VectorView std, const Vector &y, const ArrayOfVector &ys, const Index start, const Index end_tmp)
Compute the standard deviation of the ranged ys.
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