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