10#if !defined (HPP_ALIB_EXPRESSIONS_PLUGINS_DATEANDTIME)
18#if !defined (HPP_ALIB_CAMP_CALENDAR)
26#define ARG1 (*(args+1))
27#define INT(box) (box).Unbox<integer >()
28#define FLT(box) (box).Unbox<double >()
29#define DT(box) (box).Unbox<DateTime >()
30#define DUR(box) (box).Unbox<DateTime::Duration>()
31#define FUNC( name,...) Box name( Scope& scope, \
34 { (void) scope; (void) args; (void) end; __VA_ARGS__ }
36#if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
37# define TOINT(arg) arg
39# define TOINT(arg) static_cast<integer>(arg)
42namespace alib {
namespace expressions {
namespace plugins {
50DOX_MARKER([DOX_ALIB_EXPR_FToLiteral_3])
51void FToLiteral_Duration(
const Box& constantValue,
AString& expressionString )
54 auto value= constantValue.Unbox<DateTime::Duration>().InNanoseconds();
59 result=
"Milliseconds";
62 result=
"Nanoseconds";
64 if( (value % 1000) == 0 )
67 result=
"Microseconds";
68 if( (value % 1000) == 0 )
71 result=
"Milliseconds";
72 if( (value % 1000) == 0 )
76 if( (value % 60) == 0 )
80 if( (value % 60) == 0 )
84 if( (value % 24) == 0 )
97 expressionString << result <<
'(' << value <<
')' ;
99DOX_MARKER([DOX_ALIB_EXPR_FToLiteral_3])
101void FToLiteral_DateTime(
const Box& constantValue,
AString& expressionString )
105 expressionString <<
"UTCDateTime( " << ct.Year <<
','
111 << ct.Millisecond <<
')' ;
118FUNC( dateTime ,
auto qtyArgs= end-args;
120 ( qtyArgs> 1 ) ?
static_cast<int>( INT(*(args+1)) ) : 1,
121 ( qtyArgs> 2 ) ? static_cast<int>( INT(*(args+2)) ) : 1,
122 ( qtyArgs> 3 ) ? static_cast<int>( INT(*(args+3)) ) : 0,
123 ( qtyArgs> 4 ) ? static_cast<int>( INT(*(args+4)) ) : 0,
124 ( qtyArgs> 5 ) ? static_cast<int>( INT(*(args+5)) ) : 0,
125 ( qtyArgs> 6 ) ? static_cast<int>( INT(*(args+6)) ) : 0
130FUNC( utcDateTime ,
auto qtyArgs= end-args;
132 ( qtyArgs> 1 ) ?
static_cast<int>( INT(*(args+1)) ) : 1,
133 ( qtyArgs> 2 ) ? static_cast<int>( INT(*(args+2)) ) : 1,
134 ( qtyArgs> 3 ) ? static_cast<int>( INT(*(args+3)) ) : 0,
135 ( qtyArgs> 4 ) ? static_cast<int>( INT(*(args+4)) ) : 0,
136 ( qtyArgs> 5 ) ? static_cast<int>( INT(*(args+5)) ) : 0,
137 ( qtyArgs> 6 ) ? static_cast<int>( INT(*(args+6)) ) : 0
143 ct.Hour= ct.Minute= ct.Second= ct.Millisecond= 0;
146 ct.Hour= ct.Minute= ct.Second= ct.Millisecond= 0;
149FUNC( age ,
return DT(ARG0).Age(); )
150FUNC( isOlderThan ,
return DT(ARG0).IsOlderThan( DUR(ARG1) ); )
173FUNC( nanosecondsInt ,
return DateTime::Duration::FromNanoseconds ( INT(ARG0) ); )
175FUNC( microsecondsInt ,
return DateTime::Duration::FromAbsoluteMicroseconds ( INT(ARG0) ); )
176FUNC( millisecondsInt ,
return DateTime::Duration::FromAbsoluteMilliseconds ( INT(ARG0) ); )
177FUNC( secondsInt ,
return DateTime::Duration::FromAbsoluteSeconds ( INT(ARG0) ); )
178FUNC( minutesInt ,
return DateTime::Duration::FromAbsoluteMinutes ( INT(ARG0) ); )
179FUNC( hoursInt ,
return DateTime::Duration::FromAbsoluteHours ( INT(ARG0) ); )
180FUNC( daysInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) ); )
181FUNC( weeksInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) * 7 ); )
182FUNC( monthsInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) * 30 ); )
183FUNC( yearsInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) * 365 ); )
185FUNC( microsecondsFlt ,
return DateTime::Duration::FromMicroseconds ( FLT(ARG0) ); )
186FUNC( millisecondsFlt ,
return DateTime::Duration::FromMilliseconds ( FLT(ARG0) ); )
187FUNC( secondsFlt ,
return DateTime::Duration::FromSeconds ( FLT(ARG0) ); )
188FUNC( minutesFlt ,
return DateTime::Duration::FromMinutes ( FLT(ARG0) ); )
189FUNC( hoursFlt ,
return DateTime::Duration::FromHours ( FLT(ARG0) ); )
190FUNC( daysFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) ); )
191FUNC( weeksFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) * 7.0 ); )
192FUNC( monthsFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) * 30.0 ); )
193FUNC( yearsFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) * 365.0 ); )
197FUNC( inDays ,
return DUR(ARG0).InDays (); )
198FUNC( inHours ,
return DUR(ARG0).InHours (); )
199FUNC( inMinutes ,
return DUR(ARG0).InMinutes (); )
200FUNC( inSeconds ,
return DUR(ARG0).InSeconds (); )
201FUNC( inMilliseconds ,
return DUR(ARG0).InMilliseconds(); )
202FUNC( inMicroseconds ,
return DUR(ARG0).InMicroseconds(); )
203FUNC( inNanoseconds ,
return DUR(ARG0).InNanoseconds (); )
204FUNC( inHertz ,
return DUR(ARG0).InHertz(2); )
207FUNC( add_DTDUR ,
return DT(ARG0) + DUR(ARG1); )
208FUNC( add_DURDT ,
return DT(ARG1) + DUR(ARG0); )
209FUNC( sub_DTDUR ,
return DT(ARG0) - DUR(ARG1); )
210FUNC( sub_DTDT ,
return DT(ARG0) - DT(ARG1); )
211FUNC( eqDT ,
return DT(ARG0) == DT(ARG1); )
212FUNC( neqDT ,
return DT(ARG0) != DT(ARG1); )
213FUNC( gtDT ,
return DT(ARG0) > DT(ARG1); )
214FUNC( gteqDT ,
return DT(ARG0) >= DT(ARG1); )
215FUNC( smDT ,
return DT(ARG0) < DT(ARG1); )
216FUNC( smeqDT ,
return DT(ARG0) <= DT(ARG1); )
220FUNC( add_DURDUR ,
return DUR(ARG0) + DUR(ARG1); )
221FUNC( sub_DURDUR ,
return DUR(ARG0) - DUR(ARG1); )
222FUNC( mul_DURF ,
return DUR(ARG0) * FLT(ARG1); )
223FUNC( mul_FDUR ,
return DUR(ARG1) * FLT(ARG0); )
224FUNC( mul_DURI ,
return DUR(ARG0) *
static_cast<int64_t
>( INT(ARG1) ); )
225FUNC( mul_IDUR ,
return DUR(ARG1) *
static_cast<int64_t
>( INT(ARG0) ); )
226FUNC( div_DURF ,
return DUR(ARG0) / FLT(ARG1); )
227FUNC( div_DURI ,
return DUR(ARG0) /
static_cast<int64_t
>( INT(ARG1) ); )
229FUNC( eqDUR ,
return DUR(ARG0) == DUR(ARG1); )
230FUNC( neqDUR ,
return DUR(ARG0) != DUR(ARG1); )
231FUNC( gtDUR ,
return DUR(ARG0) > DUR(ARG1); )
232FUNC( gteqDUR ,
return DUR(ARG0) >= DUR(ARG1); )
233FUNC( smDUR ,
return DUR(ARG0) < DUR(ARG1); )
234FUNC( smeqDUR ,
return DUR(ARG0) <= DUR(ARG1); )
278DOX_MARKER([DOX_ALIB_EXPR_FToLiteral_2])
280boxing::BootstrapRegister<FToLiteral, boxing::TMappedTo<time::DateTime::Duration>>( FToLiteral_Duration );
281DOX_MARKER([DOX_ALIB_EXPR_FToLiteral_2])
282boxing::BootstrapRegister<FToLiteral, boxing::TMappedTo<time::DateTime >>( FToLiteral_DateTime );
286:
Calculus(
"ALib DateAndTime", compiler )
289 constexpr int tableSize= 58;
290 Token functionNames[tableSize];
291 Token::LoadResourcedTokens( EXPRESSIONS,
"CPD", functionNames
294 Token* descriptor= functionNames;
300 { *descriptor++, TOINT(1) }, { *descriptor++, TOINT( 2) }, { *descriptor++, TOINT( 3) }, { *descriptor++, TOINT( 4) },
301 { *descriptor++, TOINT(5) }, { *descriptor++, TOINT( 6) }, { *descriptor++, TOINT( 7) }, { *descriptor++, TOINT( 8) },
302 { *descriptor++, TOINT(9) }, { *descriptor++, TOINT(10) }, { *descriptor++, TOINT(11) }, { *descriptor++, TOINT(12) },
305 { *descriptor++, TOINT(0) }, { *descriptor++, TOINT(1) }, { *descriptor++, TOINT(2) }, { *descriptor++, TOINT( 3) },
306 { *descriptor++, TOINT(4) }, { *descriptor++, TOINT(5) }, { *descriptor++, TOINT(6) },
312DOX_MARKER([DOX_ALIB_EXPR_FToLiteral_1])
314DOX_MARKER([DOX_ALIB_EXPR_FToLiteral_1])
366 AddOperators( binaryOpTableDateTime );
369 "Descriptor table size mismatch: Consumed {} descriptors, {} available.",
370 descriptor - functionNames, tableSize )
384#undef BIN_ALIAS_ENTRY
#define ALIB_WARNINGS_RESTORE
#define CALCULUS_CALLBACK(func)
#define CALCULUS_SIGNATURE(BoxPointerArray)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
@ Local
Denotes local reach.
@ Local
Denotes local time.
@ UTC
Denotes UTC (coordinated universal time).
@ Get
Denotes to search data.
expressions::plugins::Calculus Calculus
Type alias in namespace alib.
strings::TString< nchar > NString
Type alias in namespace alib.
lang::system::CalendarDateTime CalendarDateTime
Type alias in namespace alib.
time::DateTime DateTime
Type alias in namespace alib.
strings::TAString< character > AString
Type alias in namespace alib.
strings::util::Token Token
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
expressions::Compiler Compiler
Type alias in namespace alib.
static ALIB_API Box DateTime
static ALIB_API Box Duration
static ALIB_API Box Integer
static ALIB_API Box Boolean
static ALIB_API Box Float
const std::tuple< String, Type, Type, CallbackDecl, Type, CTInvokable > OperatorTableEntry
static constexpr CTInvokable CTI
static ALIB_API void Bootstrap()
ALIB_API DateAndTime(Compiler &compiler)