ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
dateandtime.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header file is part of module \alib_expressions of the \aliblong.
4///
5/// \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8#ifndef HPP_ALIB_EXPRESSIONS_PLUGINS_DATEANDTIME
9#define HPP_ALIB_EXPRESSIONS_PLUGINS_DATEANDTIME
10#pragma once
11#if !defined(DOXYGEN)
12# include "alib/alib.hpp"
13#endif
14
15ALIB_ASSERT_MODULE(EXPRESSIONS)
17
18#include "alib/expressions/plugins/calculus.hpp"
19
20namespace alib { namespace expressions { namespace plugins {
21
22//==================================================================================================
23/// %Compiler plug-in that provides date an time related expression terms.
24///
25/// The identifiers, functions and operators offered by this compiler plug-in introduce \alib
26/// types \alib{time;DateTime} and \alib{time;TimePointBase::Duration} to be used with
27/// module \alib_expressions_nl.
28///
29/// All identifier and function names are defined case insensitive.
30///
31/// <b>Constants:</b><br>
32///
33/// Type | Name |Min. Abbreviation| Description
34/// --------|-------|-----------------|-------------
35/// Integer |\b January | jan | Used to compare the result of functions \p{GetMonth} and \p{GetUtcMonth}.
36/// Integer |\b February | feb | Used to compare the result of functions \p{GetMonth} and \p{GetUtcMonth}.
37/// Integer |\b March | mar | Used to compare the result of functions \p{GetMonth} and \p{GetUtcMonth}.
38/// Integer |\b April | apr | Used to compare the result of functions \p{GetMonth} and \p{GetUtcMonth}.
39/// Integer |\b May | may | Used to compare the result of functions \p{GetMonth} and \p{GetUtcMonth}.
40/// Integer |\b June | jun | Used to compare the result of functions \p{GetMonth} and \p{GetUtcMonth}.
41/// Integer |\b July | jul | Used to compare the result of functions \p{GetMonth} and \p{GetUtcMonth}.
42/// Integer |\b August | aug | Used to compare the result of functions \p{GetMonth} and \p{GetUtcMonth}.
43/// Integer |\b September| sep | Used to compare the result of functions \p{GetMonth} and \p{GetUtcMonth}.
44/// Integer |\b October | oct | Used to compare the result of functions \p{GetMonth} and \p{GetUtcMonth}.
45/// Integer |\b November | nov | Used to compare the result of functions \p{GetMonth} and \p{GetUtcMonth}.
46/// Integer |\b December | dec | Used to compare the result of functions \p{GetMonth} and \p{GetUtcMonth}.
47///
48/// Integer |\b Sunday | sun | Used to compare the result of functions \p{GetDayOfWeek} and \p{GetUtcDayOfWeek}.
49/// Integer |\b Monday | mon | Used to compare the result of functions \p{GetDayOfWeek} and \p{GetUtcDayOfWeek}.
50/// Integer |\b Tuesday | tue | Used to compare the result of functions \p{GetDayOfWeek} and \p{GetUtcDayOfWeek}.
51/// Integer |\b Wednesday| wed | Used to compare the result of functions \p{GetDayOfWeek} and \p{GetUtcDayOfWeek}.
52/// Integer |\b Thursday | thu | Used to compare the result of functions \p{GetDayOfWeek} and \p{GetUtcDayOfWeek}.
53/// Integer |\b Friday | fri | Used to compare the result of functions \p{GetDayOfWeek} and \p{GetUtcDayOfWeek}.
54/// Integer |\b Saturday | sat | Used to compare the result of functions \p{GetDayOfWeek} and \p{GetUtcDayOfWeek}.
55///
56///
57/// <br>
58/// <b>Constant Constructor Functions:</b><br>
59///
60/// Return Type | Name |Min. Abbreviation| Signature | Description |
61/// ---------------|-----------|-----------------|-----------|-------------|
62/// DateTime |\b DateTime | times |int,...| Returns a time stamp representing the calendar date in local time zone, respecting daylight saving. The first parameter is required and provides the \p{year}. Further parameters are optional and provide \p{month} (defaults to \c 1), \p{dayOfMonth} (defaults to \c 1), \p{hour} (defaults to \c 0), \p{minute} (defaults to \c 0) and \p{millisecond} (defaults to \c 0).
63/// DateTime |\b UtcDateTime | utcti |int,...| Returns a time stamp representing the calendar date in UTC time, not respecting daylight saving. The first parameter is required and provides the \p{year}. Further parameters are optional and provide \p{month} (defaults to \c 1), \p{dayOfMonth} (defaults to \c 1), \p{hour} (defaults to \c 0), \p{minute} (defaults to \c 0) and \p{millisecond} (defaults to \c 0).
64/// Duration |\b NanoSecondS | ns |int | Returns a time span object representing the given number of nanoseconds.
65/// Duration |\b MicroSecondS | mics |int | Returns a time span object representing the given (absolute) number of microseconds.
66/// Duration |\b MicroSecondS | mics |double | Returns a time span object representing the given (rational) number of microseconds.
67/// Duration |\b MillisecondS | ms |int | Returns a time span object representing the given (absolute) number of milliseconds.
68/// Duration |\b MillisecondS | ms |double | Returns a time span object representing the given (rational) number of milliseconds.
69/// Duration |\b SecondS | sec |int | Returns a time span object representing the given (absolute) number of seconds.
70/// Duration |\b SecondS | sec |double | Returns a time span object representing the given (rational) number of seconds.
71/// Duration |\b MinuteS | min |int | Returns a time span object representing the given (absolute) number of minutes.
72/// Duration |\b MinuteS | min |double | Returns a time span object representing the given (rational) number of minutes.
73/// Duration |\b Hours | hour |int | Returns a time span object representing the given (absolute) number of hours.
74/// Duration |\b Hours | hour |double | Returns a time span object representing the given (rational) number of hours.
75/// Duration |\b Days | day |int | Returns a time span object representing the given (absolute) number of days.
76/// Duration |\b Days | day |double | Returns a time span object representing the given (rational) number of days.
77/// Duration |\b Weeks | wee |int | Returns a time span object representing the given (absolute) number of weeks.
78/// Duration |\b Weeks | wee |double | Returns a time span object representing the given (rational) number of weeks.
79/// Duration |\b Months | mon |int | Returns a time span object representing the given (absolute) number of months (30 days).
80/// Duration |\b Months | mon |double | Returns a time span object representing the given (rational) number of months (30 days).
81/// Duration |\b Years | year |int | Returns a time span object representing the given (absolute) number of years (365 days).
82/// Duration |\b Years | year |double | Returns a time span object representing the given (rational) number of years (365 days).
83///
84/// <br>
85/// <b>Functions:</b><br>
86///
87/// Return Type | Name | Min. Abbreviation| Signature | Description |
88/// ---------------|-----------|------------------|-----------|-------------|
89/// DateTime | \b Now |now | ./. | Returns the actual point in time.
90/// DateTime | \b Today |today | ./. | Returns the point in time that represents the current date local date at midnight, respecting the local time zone and daylight saving.
91/// DateTime | \b UtcToday |utoday | ./. | Returns the point in time that represents the current date local date at midnight, respecting UTC time zone without daylight saving.
92/// Duration | \b Age |age | DateTime | Returns the time span between the actual point in time and the given time stamp.
93/// Boolean | \b IsOlderThan |isot | DateTime ,Duration| Returns \c true if the time span between the actual point in time and the given point in time is greater than the given duration.
94/// Integer | \b GetYear |gy | DateTime | Returns the calendar year of the time stamp, respecting the local time zone and daylight saving.
95/// Integer | \b GetMonth |gmon | DateTime | Returns the calendar month of the time stamp, respecting the local time zone and daylight saving.
96/// Integer | \b GetDay |gd | DateTime | Returns the calendar day of the time stamp, respecting the local time zone and daylight saving.
97/// Integer | \b GetDayOfWeek |gdow | DateTime | Returns the calendar dayOfWeek of the time stamp, respecting the local time zone and daylight saving.
98/// Integer | \b GetHour |gh | DateTime | Returns the calendar hour of the time stamp, respecting the local time zone and daylight saving.
99/// Integer | \b GetMinute |gmin | DateTime | Returns the calendar Minute of the time stamp, respecting the local time zone and daylight saving.
100/// Integer | \b GetMilliSecond |gms | DateTime | Returns the calendar millisecond of the time stamp, respecting the local time zone and daylight saving.
101/// Integer | \b GetUtcYear |guy | DateTime | Returns the calendar year of the time stamp, respecting UTC time zone without daylight saving.
102/// Integer | \b GetUtcMonth |gumon | DateTime | Returns the calendar month of the time stamp, respecting UTC time zone without daylight saving.
103/// Integer | \b GetUtcDay |gud | DateTime | Returns the calendar day of the time stamp, respecting UTC time zone without daylight saving.
104/// Integer | \b GetUtcDayOfWeek |gudow | DateTime | Returns the calendar dayOfWeek of the time stamp, respecting UTC time zone without daylight saving.
105/// Integer | \b GetUtcHour |guh | DateTime | Returns the calendar hour of the time stamp, respecting UTC time zone without daylight saving.
106/// Integer | \b GetUtcMinute |gumin | DateTime | Returns the calendar minute of the time stamp, respecting UTC time zone without daylight saving.
107/// Integer | \b GetUtcMillisecond|gums | DateTime | Returns the calendar millisecond of the time stamp, respecting UTC time zone without daylight saving.
108/// Float | \b InDayS |ind | Duration | Returns the time span given in days.
109/// Float | \b InHourS |inh | Duration | Returns the time span given in hours.
110/// Float | \b InMinuteS |inmin | Duration | Returns the time span given in minutes.
111/// Float | \b InSecondS |ins | Duration | Returns the time span given in seconds.
112/// Float | \b InMilliSecondS |inms | Duration | Returns the time span given in milliseconds.
113/// Float | \b InMicroSecondS |inmics | Duration | Returns the time span given in microseconds.
114/// Float | \b InNanoSecondS |inns | Duration | Returns the time span given in nanoseconds.
115/// Float | \b InHertZ |inhz | Duration | Returns the time span given in hertz (1/second).
116///
117/// <br>
118/// <b>Binary Operators:</b><br>
119///
120/// Return Type | Lhs Type | Operator | Rhs Type | Description|
121/// ---------------|----------|----------|----------|------------|
122/// DateTime | DateTime |<c>+</c> | Duration | Adds a time span to a time stamp.
123/// DateTime | Duration |<c>+</c> | DateTime | Adds a time span to a time stamp.
124/// DateTime | DateTime |<c>-</c> | DateTime | Subtracts two time stamps resulting in a time span.
125/// DateTime | DateTime |<c>-</c> | Duration | Subtracts a time span from time stamp.
126/// Duration | Duration |<c>+</c> | Duration | Adds two time spans.
127/// Duration | Duration |<c>-</c> | Duration | Subtracts rhs-value from lhs-value.
128/// Duration | Duration |<c>*</c> | Float | Multiplies a time span by a given floating point value.
129/// Duration | Float |<c>*</c> | Duration | Multiplies a time span by a given floating point value.
130/// Duration | Duration |<c>*</c> | Integer | Multiplies a time span by a given integral value.
131/// Duration | Integer |<c>*</c> | Duration | Multiplies a time span by a given integral value.
132/// Duration | Duration |<c>/</c> | Float | Divides a time span by a given floating point value.
133/// Duration | Duration |<c>/</c> | Integer | Divides a time span by a given integral value.
134/// Boolean | DateTime |<c>==</c>| DateTime | Compares two time stamp objects.
135/// Boolean | Duration |<c>==</c>| Duration | Compares two time span objects.
136/// Boolean | DateTime |<c>!=</c>| DateTime | Compares two time stamp objects.
137/// Boolean | Duration |<c>!=</c>| Duration | Compares two time span objects.
138/// Boolean | DateTime |<c><</c> | DateTime | Compares two time stamp objects.
139/// Boolean | Duration |<c><</c> | Duration | Compares two time span objects.
140/// Boolean | DateTime |<c><=</c>| DateTime | Compares two time stamp objects.
141/// Boolean | Duration |<c><=</c>| Duration | Compares two time span objects.
142/// Boolean | DateTime |<c>></c> | DateTime | Compares two time stamp objects.
143/// Boolean | Duration |<c>></c> | Duration | Compares two time span objects.
144/// Boolean | DateTime |<c>>=</c>| DateTime | Compares two time stamp objects.
145/// Boolean | Duration |<c>>=</c>| Duration | Compares two time span objects.
146///
147/// # Reference Documentation #
148//==================================================================================================
150{
151 //==============================================================================================
152 /// Constructor. Creates the hash maps.
153 /// @param compiler The compiler we will get attached to.
154 //==============================================================================================
156
157 //==============================================================================================
158 /// Virtual destructor
159 //==============================================================================================
160 virtual ~DateAndTime() override {}
161
162 //==============================================================================================
163 /// Static initialization function.
164 /// Called once during \ref alib_manual_bootstrapping "library initialization".
165 //==============================================================================================
166 static ALIB_API
167 void Bootstrap();
168};
169
170
171}}} // namespace [alib::expressions::detail]
172
173#endif // HPP_ALIB_EXPRESSIONS_PLUGINS_DATEANDTIME
174
#define ALIB_ASSERT_MODULE(modulename)
Definition alib.hpp:223
#define ALIB_API
Definition alib.hpp:639
Definition alib.cpp:69
virtual ~DateAndTime() override
Virtual destructor.
ALIB_API DateAndTime(Compiler &compiler)