NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
datetimetools.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2021 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#ifndef DATETIMETOOLS_HPP
20#define DATETIMETOOLS_HPP
21
22#include <ctime>
23#include <chrono>
24#include "date/date.h"
25
32{
34 std::chrono::hours m_hours;
35 std::chrono::minutes m_minutes;
36 std::chrono::seconds m_seconds;
37 std::chrono::milliseconds m_millisecs;
38 std::chrono::microseconds m_microsecs;
39
40 time_stamp();
41};
42
43
49{
50 std::chrono::minutes Bias;
51 std::chrono::minutes DayLightBias;
52};
53
54
60using sys_time_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::microseconds>;
61
62
64
67
70
72__time64_t getTime_tFromTimeStamp(const time_stamp& ts);
73
74double to_double(sys_time_point tp);
76
77size_t getWeekDay(sys_time_point tp);
78size_t getWeekNum(sys_time_point tp);
79
81
82#endif // DATETIMETOOLS_HPP
83
__time64_t getTime_tFromTimeStamp(const time_stamp &ts)
Convert a time_stamp to a __time64_t.
date::year_month_day dateFromTime_t(__time64_t t)
Return the date extracted from the passed __time64_t.
size_t getWeekDay(sys_time_point tp)
Returns the weekday of the selected timepoint as an unsigned integer with Monday being 1u and Sunday ...
sys_time_point to_timePoint(double d)
Convert a double to a sys_time_point assuming the double is in units of seconds.
time_stamp getTimeStampFromTime_t(__time64_t t)
Return a time_stamp instance converted from the passed __time64_t.
size_t getWeekNum(sys_time_point tp)
Returns the weeknum of the selected timepoint as an unsigned integer.
double to_double(sys_time_point tp)
Convert a sys_time_point to a double. The double is returned in units of seconds.
date::year_month_day dateFromTimePoint(sys_time_point tp)
Return the date extracted from the passed sys_time_point.
sys_time_point sys_time_now()
Returns the current time as a sys_time_point (i.e. a std::chrono::time_point with microseconds precis...
time_stamp getTimeStampFromTimePoint(sys_time_point tp)
Return a time_stamp instance converted from the passed sys_time_point.
std::chrono::time_point< std::chrono::system_clock, std::chrono::microseconds > sys_time_point
This is a typedef for a custom system_clock time_point with microseconds precision.
time_zone getCurrentTimeZone()
Return the current time_zone of the system.
sys_time_point getTimePointFromTimeStamp(const time_stamp &ts)
Convert a time_stamp to a sys_time_point.
This structure defines all fields necessary to create a time stamp or a formatted date.
time_stamp()
Default constructor for zero-initialisation.
date::year_month_day m_ymd
std::chrono::microseconds m_microsecs
std::chrono::minutes m_minutes
std::chrono::seconds m_seconds
std::chrono::hours m_hours
std::chrono::milliseconds m_millisecs
This structure defines the information for a time zone.
std::chrono::minutes DayLightBias
std::chrono::minutes Bias