ARTS 2.5.4 (git: 4c0d3b4d)
m_artstime.cc
Go to the documentation of this file.
1/* Copyright (C) 2020
2 * Richard Larsson <ric.larsson@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA. */
18
27#include <thread>
28
29#include "matpackI.h"
30#include "artstime.h"
31#include "messages.h"
32#include "sorting.h"
33
34
35void timeNow(Time& time, const Verbosity&)
36{
37 time = Time();
38}
39
40
41void Duration(Numeric& duration, const Time& t0, const Time& t1, const Verbosity&)
42{
43 duration = std::chrono::duration_cast<TimeStep>(t1 - t0).count();
44}
45
46
47void Sleep(const Numeric& duration, const Verbosity&)
48{
49 std::this_thread::sleep_for(TimeStep(duration));
50}
51
52
53void timeSleep(const Time& time, const Verbosity&)
54{
55 std::this_thread::sleep_until(time.time);
56}
57
58
60{
61 const Time time;
62 const Time localtime = Time(time.toStruct());
63 const Time gmtime = Time(time.toGMTStruct());
64 dt = std::chrono::duration_cast<TimeStep>(localtime - gmtime).count();
65}
66
67
68void timeOffset(Time& time, const Numeric& offset, const Verbosity&)
69{
70 time += TimeStep(offset);
71}
72
73
74void time_gridOffset(ArrayOfTime& time_grid, const Numeric& offset, const Verbosity& verbosity)
75{
76 for (Time& time: time_grid)
77 timeOffset(time, offset, verbosity);
78}
Stuff related to time in ARTS.
std::chrono::duration< Numeric > TimeStep
A duration of time, 1 full tick should be 1 second.
Definition: artstime.h:39
This can be used to make arrays out of anything.
Definition: array.h:108
void timeOffset(Time &time, const Numeric &offset, const Verbosity &)
WORKSPACE METHOD: timeOffset.
Definition: m_artstime.cc:68
void time_gridOffset(ArrayOfTime &time_grid, const Numeric &offset, const Verbosity &verbosity)
WORKSPACE METHOD: time_gridOffset.
Definition: m_artstime.cc:74
void timeNow(Time &time, const Verbosity &)
WORKSPACE METHOD: timeNow.
Definition: m_artstime.cc:35
void Sleep(const Numeric &duration, const Verbosity &)
WORKSPACE METHOD: Sleep.
Definition: m_artstime.cc:47
void timeSleep(const Time &time, const Verbosity &)
WORKSPACE METHOD: timeSleep.
Definition: m_artstime.cc:53
void Duration(Numeric &duration, const Time &t0, const Time &t1, const Verbosity &)
WORKSPACE METHOD: Duration.
Definition: m_artstime.cc:41
void LocalTimeOffset(Numeric &dt, const Verbosity &)
WORKSPACE METHOD: LocalTimeOffset.
Definition: m_artstime.cc:59
Implementation of Matrix, Vector, and such stuff.
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Declarations having to do with the four output streams.
Contains sorting routines.
Class to handle time in ARTS.
Definition: artstime.h:42
std::chrono::system_clock::time_point time
Definition: artstime.h:43
std::tm toStruct() const
Definition: artstime.h:60
std::tm toGMTStruct() const
Definition: artstime.h:67