37 using TimeStep = std::chrono::duration<Numeric>;
42 std::chrono::system_clock::time_point
mtime;
51 Time() : mtime(
std::chrono::system_clock::now()) {}
52 explicit Time(std::time_t t) : mtime(
std::chrono::system_clock::from_time_t(t)) {}
56 const std::chrono::system_clock::time_point&
Data()
const {
return mtime;}
59 std::time_t
toTimeT()
const {
return std::chrono::system_clock::to_time_t(mtime);}
60 std::tm
toStruct()
const {std::time_t x=
toTimeT(); std::tm* y = std::localtime(&x);
return *y;}
69 template <
typename T,
typename R>
Time&
operator+=(
const std::chrono::duration<T, R>& dt) {mtime += std::chrono::duration_cast<
InternalTimeStep>(dt);
return *
this;}
70 template <
typename T,
typename R>
Time&
operator-=(
const std::chrono::duration<T, R>& dt) {mtime -= std::chrono::duration_cast<
InternalTimeStep>(dt);
return *
this;}
71 template <
typename T,
typename R>
Time operator+(
const std::chrono::duration<T, R>& dt)
const {
return (
Time(*
this) += dt);}
72 template <
typename T,
typename R>
Time operator-(
const std::chrono::duration<T, R>& dt)
const {
return (
Time(*
this) -= dt);}
93 inline std::ostream&
operator<<(std::ostream& os,
const TimeStep& dt) {
return os << dt.count() <<
" seconds";}
INDEX Index
The type to use for all integer numbers and indices.
std::time_t toTimeT() const
std::ostream & operator<<(std::ostream &os, const Time &t)
Output for Time.
std::chrono::system_clock::time_point mtime
Numeric PartOfSecond() const
Class to handle time in ARTS.
Time next_even(const Time &t, const TimeStep &dt)
Returns the next time after t with an even time-step.
std::chrono::duration< Numeric > TimeStep
A duration of time, 1 full tick should be 1 second.
InternalTimeStep EpochTime() const
Index Version() const noexcept
std::istream & operator>>(std::istream &is, Time &t)
Input for Time.
This file contains the definition of Array.
Time & operator-=(const std::chrono::duration< T, R > &dt)
TimeStep seconds_into_day() const
ArrayOfIndex time_steps(const ArrayOfTime ×, const String &step)
Finds the index matching demands in a list of times.
decltype(mtime)::duration InternalTimeStep
const std::chrono::system_clock::time_point & Data() const
Time operator+(const std::chrono::duration< T, R > &dt) const
NUMERIC Numeric
The type to use for all floating point numbers.
Time & operator+=(const std::chrono::duration< T, R > &dt)
This can be used to make arrays out of anything.
std::tm toGMTStruct() const
bool operator<(const Time &t) const
Time mean_time(const ArrayOfTime &ts, Index s=0, Index e=-1)
Computes the average time in a list.
InternalTimeStep operator-(const Time &t) const
Time operator-(const std::chrono::duration< T, R > &dt) const
This file contains the definition of String, the ARTS string class.
bool operator==(const Time &t) const