NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
datetimetools.hpp File Reference
#include <ctime>
#include <chrono>
#include "date/date.h"
Include dependency graph for datetimetools.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  time_stamp
 This structure defines all fields necessary to create a time stamp or a formatted date. More...
 
struct  time_zone
 This structure defines the information for a time zone. More...
 

Typedefs

using sys_time_point = std::chrono::time_point< std::chrono::system_clock, std::chrono::microseconds >
 This is a typedef for a custom system_clock time_point with microseconds precision. More...
 

Functions

sys_time_point sys_time_now ()
 Returns the current time as a sys_time_point (i.e. a std::chrono::time_point with microseconds precision). More...
 
date::year_month_day dateFromTimePoint (sys_time_point tp)
 Return the date extracted from the passed sys_time_point. More...
 
date::year_month_day dateFromTime_t (__time64_t t)
 Return the date extracted from the passed __time64_t. More...
 
time_stamp getTimeStampFromTimePoint (sys_time_point tp)
 Return a time_stamp instance converted from the passed sys_time_point. More...
 
time_stamp getTimeStampFromTime_t (__time64_t t)
 Return a time_stamp instance converted from the passed __time64_t. More...
 
sys_time_point getTimePointFromTimeStamp (const time_stamp &ts)
 Convert a time_stamp to a sys_time_point. More...
 
__time64_t getTime_tFromTimeStamp (const time_stamp &ts)
 Convert a time_stamp to a __time64_t. More...
 
double to_double (sys_time_point tp)
 Convert a sys_time_point to a double. The double is returned in units of seconds. More...
 
sys_time_point to_timePoint (double d)
 Convert a double to a sys_time_point assuming the double is in units of seconds. More...
 
size_t getWeekDay (sys_time_point tp)
 Returns the weekday of the selected timepoint as an unsigned integer with Monday being 1u and Sunday 7u. More...
 
size_t getWeekNum (sys_time_point tp)
 Returns the weeknum of the selected timepoint as an unsigned integer. More...
 
time_zone getCurrentTimeZone ()
 Return the current time_zone of the system. More...
 

Typedef Documentation

◆ sys_time_point

using sys_time_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::microseconds>

This is a typedef for a custom system_clock time_point with microseconds precision.

Definition at line 60 of file datetimetools.hpp.

Function Documentation

◆ dateFromTime_t()

date::year_month_day dateFromTime_t ( __time64_t  t)

Return the date extracted from the passed __time64_t.

Parameters
t__time64_t
Returns
date::year_month_day

Definition at line 73 of file datetimetools.cpp.

References dateFromTimePoint().

Here is the call graph for this function:

◆ dateFromTimePoint()

date::year_month_day dateFromTimePoint ( sys_time_point  tp)

Return the date extracted from the passed sys_time_point.

Parameters
tpsys_time_point
Returns
date::year_month_day

Definition at line 59 of file datetimetools.cpp.

Referenced by dateFromTime_t(), and getTimeStampFromTimePoint().

◆ getCurrentTimeZone()

time_zone getCurrentTimeZone ( )

Return the current time_zone of the system.

Returns
time_zone

Definition at line 235 of file datetimetools.cpp.

Referenced by strfnc_timeformat(), strfnc_to_time(), and toString().

◆ getTime_tFromTimeStamp()

__time64_t getTime_tFromTimeStamp ( const time_stamp ts)

Convert a time_stamp to a __time64_t.

Parameters
tsconst time_stamp&
Returns
__time64_t

Definition at line 158 of file datetimetools.cpp.

References getTimePointFromTimeStamp().

Here is the call graph for this function:

◆ getTimePointFromTimeStamp()

sys_time_point getTimePointFromTimeStamp ( const time_stamp ts)

◆ getTimeStampFromTime_t()

time_stamp getTimeStampFromTime_t ( __time64_t  t)

Return a time_stamp instance converted from the passed __time64_t.

Parameters
t__time64_t
Returns
time_stamp

Definition at line 122 of file datetimetools.cpp.

References getTimeStampFromTimePoint().

Here is the call graph for this function:

◆ getTimeStampFromTimePoint()

time_stamp getTimeStampFromTimePoint ( sys_time_point  tp)

Return a time_stamp instance converted from the passed sys_time_point.

Parameters
tpsys_time_point
Returns
time_stamp

Definition at line 89 of file datetimetools.cpp.

References dateFromTimePoint(), time_stamp::m_hours, time_stamp::m_microsecs, time_stamp::m_millisecs, time_stamp::m_minutes, time_stamp::m_seconds, and time_stamp::m_ymd.

Referenced by getTimeStampFromTime_t(), parser_date(), strfnc_timeformat(), strfnc_to_time(), StrToTime(), and toString().

Here is the call graph for this function:

◆ getWeekDay()

size_t getWeekDay ( sys_time_point  tp)

Returns the weekday of the selected timepoint as an unsigned integer with Monday being 1u and Sunday 7u.

Parameters
tpsys_time_point
Returns
size_t

Definition at line 206 of file datetimetools.cpp.

References date::weekday::iso_encoding().

Referenced by strfnc_weekday().

Here is the call graph for this function:

◆ getWeekNum()

size_t getWeekNum ( sys_time_point  tp)

Returns the weeknum of the selected timepoint as an unsigned integer.

Parameters
tpsys_time_point
Returns
size_t

Definition at line 221 of file datetimetools.cpp.

Referenced by parser_weeknum().

◆ sys_time_now()

sys_time_point sys_time_now ( )

Returns the current time as a sys_time_point (i.e. a std::chrono::time_point with microseconds precision).

Returns
sys_time_point

Definition at line 45 of file datetimetools.cpp.

Referenced by parser_time(), DetachedLogger::push_line(), strfnc_to_time(), and StrToTime().

◆ to_double()

double to_double ( sys_time_point  tp)

Convert a sys_time_point to a double. The double is returned in units of seconds.

Parameters
tpsys_time_point
Returns
double

Definition at line 173 of file datetimetools.cpp.

Referenced by StringColumn::convert(), CategoricalColumn::convert(), CellValueShaderDialog::OnButtonClick(), parser_time(), DateTimeColumn::setValue(), NumeRe::Table::setValueAsString(), strfnc_textparse(), strfnc_to_time(), and windowSystemTimeToDouble().

◆ to_timePoint()

sys_time_point to_timePoint ( double  d)

Convert a double to a sys_time_point assuming the double is in units of seconds.

Parameters
ddouble
Returns
sys_time_point

Definition at line 187 of file datetimetools.cpp.

References mu::rint().

Referenced by DateTimeColumn::convert(), DateTimeColumn::getValueAsInternalString(), parser_date(), parser_weeknum(), strfnc_timeformat(), and strfnc_weekday().

Here is the call graph for this function: