22#define ARG1 (*(args+1))
23#define INT(box) (box).Unbox<integer >()
24#define FLT(box) (box).Unbox<double >()
25#define DT(box) (box).Unbox<DateTime >()
26#define DUR(box) (box).Unbox<DateTime::Duration>()
27#define FUNC( name,...) Box name( Scope& scope, \
30 { (void) scope; (void) args; (void) end; __VA_ARGS__ }
32#if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
33# define TOINT(arg) arg
35# define TOINT(arg) static_cast<integer>(arg)
38namespace alib {
namespace expressions {
namespace plugins {
46DOX_MARKER([DOX_EXPR_FToLiteral_3])
47void FToLiteral_Duration(
const Box& constantValue,
AString& expressionString )
50 auto value= constantValue.Unbox<DateTime::Duration>().InNanoseconds();
55 result=
"Milliseconds";
58 result=
"Nanoseconds";
60 if( (value % 1000) == 0 )
63 result=
"Microseconds";
64 if( (value % 1000) == 0 )
67 result=
"Milliseconds";
68 if( (value % 1000) == 0 )
72 if( (value % 60) == 0 )
76 if( (value % 60) == 0 )
80 if( (value % 24) == 0 )
93 expressionString << result <<
'(' << value <<
')' ;
95DOX_MARKER([DOX_EXPR_FToLiteral_3])
97void FToLiteral_DateTime(
const Box& constantValue,
AString& expressionString )
101 expressionString <<
"UTCDateTime( " << ct.Year <<
','
107 << ct.Millisecond <<
')' ;
114FUNC( dateTime ,
auto qtyArgs= end-args;
116 ( qtyArgs> 1 ) ?
static_cast<int>( INT(*(args+1)) ) : 1,
117 ( qtyArgs> 2 ) ?
static_cast<int>( INT(*(args+2)) ) : 1,
118 ( qtyArgs> 3 ) ?
static_cast<int>( INT(*(args+3)) ) : 0,
119 ( qtyArgs> 4 ) ?
static_cast<int>( INT(*(args+4)) ) : 0,
120 ( qtyArgs> 5 ) ?
static_cast<int>( INT(*(args+5)) ) : 0,
121 ( qtyArgs> 6 ) ?
static_cast<int>( INT(*(args+6)) ) : 0
126FUNC( utcDateTime ,
auto qtyArgs= end-args;
128 ( qtyArgs> 1 ) ?
static_cast<int>( INT(*(args+1)) ) : 1,
129 ( qtyArgs> 2 ) ?
static_cast<int>( INT(*(args+2)) ) : 1,
130 ( qtyArgs> 3 ) ?
static_cast<int>( INT(*(args+3)) ) : 0,
131 ( qtyArgs> 4 ) ?
static_cast<int>( INT(*(args+4)) ) : 0,
132 ( qtyArgs> 5 ) ?
static_cast<int>( INT(*(args+5)) ) : 0,
133 ( qtyArgs> 6 ) ?
static_cast<int>( INT(*(args+6)) ) : 0
139 ct.
Hour= ct.Minute= ct.Second= ct.Millisecond= 0;
142 ct.
Hour= ct.Minute= ct.Second= ct.Millisecond= 0;
145FUNC( age ,
return DT(ARG0).Age(); )
146FUNC( isOlderThan ,
return DT(ARG0).IsOlderThan( DUR(ARG1) ); )
169FUNC( nanosecondsInt ,
return DateTime::Duration::FromNanoseconds ( INT(ARG0) ); )
171FUNC( microsecondsInt ,
return DateTime::Duration::FromAbsoluteMicroseconds ( INT(ARG0) ); )
172FUNC( millisecondsInt ,
return DateTime::Duration::FromAbsoluteMilliseconds ( INT(ARG0) ); )
173FUNC( secondsInt ,
return DateTime::Duration::FromAbsoluteSeconds ( INT(ARG0) ); )
174FUNC( minutesInt ,
return DateTime::Duration::FromAbsoluteMinutes ( INT(ARG0) ); )
175FUNC( hoursInt ,
return DateTime::Duration::FromAbsoluteHours ( INT(ARG0) ); )
176FUNC( daysInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) ); )
177FUNC( weeksInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) * 7 ); )
178FUNC( monthsInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) * 30 ); )
179FUNC( yearsInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) * 365 ); )
181FUNC( microsecondsFlt ,
return DateTime::Duration::FromMicroseconds ( FLT(ARG0) ); )
182FUNC( millisecondsFlt ,
return DateTime::Duration::FromMilliseconds ( FLT(ARG0) ); )
183FUNC( secondsFlt ,
return DateTime::Duration::FromSeconds ( FLT(ARG0) ); )
184FUNC( minutesFlt ,
return DateTime::Duration::FromMinutes ( FLT(ARG0) ); )
185FUNC( hoursFlt ,
return DateTime::Duration::FromHours ( FLT(ARG0) ); )
186FUNC( daysFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) ); )
187FUNC( weeksFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) * 7.0 ); )
188FUNC( monthsFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) * 30.0 ); )
189FUNC( yearsFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) * 365.0 ); )
193FUNC( inDays ,
return DUR(ARG0).InDays (); )
194FUNC( inHours ,
return DUR(ARG0).InHours (); )
195FUNC( inMinutes ,
return DUR(ARG0).InMinutes (); )
196FUNC( inSeconds ,
return DUR(ARG0).InSeconds (); )
197FUNC( inMilliseconds ,
return DUR(ARG0).InMilliseconds(); )
198FUNC( inMicroseconds ,
return DUR(ARG0).InMicroseconds(); )
199FUNC( inNanoseconds ,
return DUR(ARG0).InNanoseconds (); )
200FUNC( inHertz ,
return DUR(ARG0).InHertz(2); )
203FUNC( add_DTDUR ,
return DT(ARG0) + DUR(ARG1); )
204FUNC( add_DURDT ,
return DT(ARG1) + DUR(ARG0); )
205FUNC( sub_DTDUR ,
return DT(ARG0) - DUR(ARG1); )
206FUNC( sub_DTDT ,
return DT(ARG0) - DT(ARG1); )
207FUNC( eqDT ,
return DT(ARG0) == DT(ARG1); )
208FUNC( neqDT ,
return DT(ARG0) != DT(ARG1); )
209FUNC( gtDT ,
return DT(ARG0) > DT(ARG1); )
210FUNC( gteqDT ,
return DT(ARG0) >= DT(ARG1); )
211FUNC( smDT ,
return DT(ARG0) < DT(ARG1); )
212FUNC( smeqDT ,
return DT(ARG0) <= DT(ARG1); )
216FUNC( add_DURDUR ,
return DUR(ARG0) + DUR(ARG1); )
217FUNC( sub_DURDUR ,
return DUR(ARG0) - DUR(ARG1); )
218FUNC( mul_DURF ,
return DUR(ARG0) * FLT(ARG1); )
219FUNC( mul_FDUR ,
return DUR(ARG1) * FLT(ARG0); )
220FUNC( mul_DURI ,
return DUR(ARG0) *
static_cast<int64_t
>( INT(ARG1) ); )
221FUNC( mul_IDUR ,
return DUR(ARG1) *
static_cast<int64_t
>( INT(ARG0) ); )
222FUNC( div_DURF ,
return DUR(ARG0) / FLT(ARG1); )
223FUNC( div_DURI ,
return DUR(ARG0) /
static_cast<int64_t
>( INT(ARG1) ); )
225FUNC( eqDUR ,
return DUR(ARG0) == DUR(ARG1); )
226FUNC( neqDUR ,
return DUR(ARG0) != DUR(ARG1); )
227FUNC( gtDUR ,
return DUR(ARG0) > DUR(ARG1); )
228FUNC( gteqDUR ,
return DUR(ARG0) >= DUR(ARG1); )
229FUNC( smDUR ,
return DUR(ARG0) < DUR(ARG1); )
230FUNC( smeqDUR ,
return DUR(ARG0) <= DUR(ARG1); )
274DOX_MARKER([DOX_EXPR_FToLiteral_2])
277DOX_MARKER([DOX_EXPR_FToLiteral_2])
285 constexpr int tableSize= 58;
286 Token functionNames[tableSize];
287 Token::LoadResourcedTokens( EXPRESSIONS,
"CPD", functionNames
290 Token* descriptor= functionNames;
296 { *descriptor++, TOINT(1) }, { *descriptor++, TOINT( 2) }, { *descriptor++, TOINT( 3) }, { *descriptor++, TOINT( 4) },
297 { *descriptor++, TOINT(5) }, { *descriptor++, TOINT( 6) }, { *descriptor++, TOINT( 7) }, { *descriptor++, TOINT( 8) },
298 { *descriptor++, TOINT(9) }, { *descriptor++, TOINT(10) }, { *descriptor++, TOINT(11) }, { *descriptor++, TOINT(12) },
301 { *descriptor++, TOINT(0) }, { *descriptor++, TOINT(1) }, { *descriptor++, TOINT(2) }, { *descriptor++, TOINT( 3) },
302 { *descriptor++, TOINT(4) }, { *descriptor++, TOINT(5) }, { *descriptor++, TOINT(6) },
308DOX_MARKER([DOX_EXPR_FToLiteral_1])
310DOX_MARKER([DOX_EXPR_FToLiteral_1])
362 AddOperators( binaryOpTableDateTime );
365 "Descriptor table size mismatch: Consumed {} descriptors, {} available.",
366 descriptor - functionNames, tableSize )
380#undef BIN_ALIAS_ENTRY
int Hour
The calendar hour (0..23).
ALIB_API DateTime Get(lang::Timezone timezone=lang::Timezone::Local) const
#define ALIB_WARNINGS_RESTORE
#define CALCULUS_CALLBACK(func)
#define CALCULUS_SIGNATURE(BoxPointerArray)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
void BootstrapRegister(typename TFDecl::Signature function)
@ DateAndTime
Collection of date and time functions based on alib::time.
@ Local
Denotes local time.
@ UTC
Denotes UTC (coordinated universal time).
expressions::plugins::Calculus Calculus
Type alias in namespace alib.
strings::TString< nchar > NString
Type alias in namespace alib.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
lang::system::CalendarDateTime CalendarDateTime
Type alias in namespace alib.
time::DateTime DateTime
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
Sample type-box for date and time values of type DateTime).
static ALIB_API Box Duration
Sample type-box for values of type DateTime::Duration).
static ALIB_API Box Integer
Sample type-box for integer types. (Precisely for type integer.)
static ALIB_API Box Boolean
Sample type-box for C++ type bool.
static ALIB_API Box Float
Sample type-box for C++ type double.
const std::tuple< String, Type, Type, CallbackDecl, Type, CTInvokable > OperatorTableEntry
static constexpr CTInvokable CTI
static ALIB_API void Bootstrap()
ALIB_API DateAndTime(Compiler &compiler)