8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
36#define ARG1 (*(args+1))
37#define INT(box) (box).Unbox<integer >()
38#define FLT(box) (box).Unbox<double >()
39#define DT(box) (box).Unbox<DateTime >()
40#define DUR(box) (box).Unbox<DateTime::Duration>()
41#define FUNC( name,...) Box name( Scope& scope, \
44 { (void) scope; (void) args; (void) end; __VA_ARGS__ }
46#if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
47# define TOINT(arg) arg
49# define TOINT(arg) integer(arg)
60DOX_MARKER([DOX_EXPR_FToLiteral_3])
61void FToLiteral_Duration(
const Box& constantValue,
AString& expressionString )
64 auto value= constantValue.Unbox<DateTime::Duration>().InNanoseconds();
69 result=
"Milliseconds";
72 result=
"Nanoseconds";
74 if( (value % 1000) == 0 )
77 result=
"Microseconds";
78 if( (value % 1000) == 0 )
81 result=
"Milliseconds";
82 if( (value % 1000) == 0 )
86 if( (value % 60) == 0 )
90 if( (value % 60) == 0 )
94 if( (value % 24) == 0 )
107 expressionString << result <<
'(' << value <<
')' ;
109DOX_MARKER([DOX_EXPR_FToLiteral_3])
111void FToLiteral_DateTime(
const Box& constantValue,
AString& expressionString )
115 expressionString <<
"UTCDateTime( " << ct.Year <<
','
121 << ct.Millisecond <<
')' ;
128FUNC( dateTime ,
auto qtyArgs= end-args;
130 ( qtyArgs> 1 ) ?
int( INT(*(args+1)) ) : 1,
131 ( qtyArgs> 2 ) ?
int( INT(*(args+2)) ) : 1,
132 ( qtyArgs> 3 ) ?
int( INT(*(args+3)) ) : 0,
133 ( qtyArgs> 4 ) ?
int( INT(*(args+4)) ) : 0,
134 ( qtyArgs> 5 ) ?
int( INT(*(args+5)) ) : 0,
135 ( qtyArgs> 6 ) ?
int( INT(*(args+6)) ) : 0
140FUNC( utcDateTime ,
auto qtyArgs= end-args;
142 ( qtyArgs> 1 ) ?
int( INT(*(args+1)) ) : 1,
143 ( qtyArgs> 2 ) ?
int( INT(*(args+2)) ) : 1,
144 ( qtyArgs> 3 ) ?
int( INT(*(args+3)) ) : 0,
145 ( qtyArgs> 4 ) ?
int( INT(*(args+4)) ) : 0,
146 ( qtyArgs> 5 ) ?
int( INT(*(args+5)) ) : 0,
147 ( qtyArgs> 6 ) ?
int( INT(*(args+6)) ) : 0
153 ct.
Hour= ct.Minute= ct.Second= ct.Millisecond= 0;
156 ct.
Hour= ct.Minute= ct.Second= ct.Millisecond= 0;
159FUNC( age ,
return DT(ARG0).Age(); )
160FUNC( isOlderThan ,
return DT(ARG0).IsOlderThan( DUR(ARG1) ); )
183FUNC( nanosecondsInt ,
return DateTime::Duration::FromNanoseconds ( INT(ARG0) ); )
185FUNC( microsecondsInt ,
return DateTime::Duration::FromAbsoluteMicroseconds ( INT(ARG0) ); )
186FUNC( millisecondsInt ,
return DateTime::Duration::FromAbsoluteMilliseconds ( INT(ARG0) ); )
187FUNC( secondsInt ,
return DateTime::Duration::FromAbsoluteSeconds ( INT(ARG0) ); )
188FUNC( minutesInt ,
return DateTime::Duration::FromAbsoluteMinutes ( INT(ARG0) ); )
189FUNC( hoursInt ,
return DateTime::Duration::FromAbsoluteHours ( INT(ARG0) ); )
190FUNC( daysInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) ); )
191FUNC( weeksInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) * 7 ); )
192FUNC( monthsInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) * 30 ); )
193FUNC( yearsInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) * 365 ); )
195FUNC( microsecondsFlt ,
return DateTime::Duration::FromMicroseconds ( FLT(ARG0) ); )
196FUNC( millisecondsFlt ,
return DateTime::Duration::FromMilliseconds ( FLT(ARG0) ); )
197FUNC( secondsFlt ,
return DateTime::Duration::FromSeconds ( FLT(ARG0) ); )
198FUNC( minutesFlt ,
return DateTime::Duration::FromMinutes ( FLT(ARG0) ); )
199FUNC( hoursFlt ,
return DateTime::Duration::FromHours ( FLT(ARG0) ); )
200FUNC( daysFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) ); )
201FUNC( weeksFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) * 7.0 ); )
202FUNC( monthsFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) * 30.0 ); )
203FUNC( yearsFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) * 365.0 ); )
207FUNC( inDays ,
return DUR(ARG0).InDays (); )
208FUNC( inHours ,
return DUR(ARG0).InHours (); )
209FUNC( inMinutes ,
return DUR(ARG0).InMinutes (); )
210FUNC( inSeconds ,
return DUR(ARG0).InSeconds (); )
211FUNC( inMilliseconds ,
return DUR(ARG0).InMilliseconds(); )
212FUNC( inMicroseconds ,
return DUR(ARG0).InMicroseconds(); )
213FUNC( inNanoseconds ,
return DUR(ARG0).InNanoseconds (); )
214FUNC( inHertz ,
return DUR(ARG0).InHertz(2); )
217FUNC( add_DTDUR ,
return DT(ARG0) + DUR(ARG1); )
218FUNC( add_DURDT ,
return DT(ARG1) + DUR(ARG0); )
219FUNC( sub_DTDUR ,
return DT(ARG0) - DUR(ARG1); )
220FUNC( sub_DTDT ,
return DT(ARG0) - DT(ARG1); )
221FUNC( eqDT ,
return DT(ARG0) == DT(ARG1); )
222FUNC( neqDT ,
return DT(ARG0) != DT(ARG1); )
223FUNC( gtDT ,
return DT(ARG0) > DT(ARG1); )
224FUNC( gteqDT ,
return DT(ARG0) >= DT(ARG1); )
225FUNC( smDT ,
return DT(ARG0) < DT(ARG1); )
226FUNC( smeqDT ,
return DT(ARG0) <= DT(ARG1); )
230FUNC( add_DURDUR ,
return DUR(ARG0) + DUR(ARG1); )
231FUNC( sub_DURDUR ,
return DUR(ARG0) - DUR(ARG1); )
232FUNC( mul_DURF ,
return DUR(ARG0) * FLT(ARG1); )
233FUNC( mul_FDUR ,
return DUR(ARG1) * FLT(ARG0); )
234FUNC( mul_DURI ,
return DUR(ARG0) * int64_t( INT(ARG1) ); )
235FUNC( mul_IDUR ,
return DUR(ARG1) * int64_t( INT(ARG0) ); )
236FUNC( div_DURF ,
return DUR(ARG0) / FLT(ARG1); )
237FUNC( div_DURI ,
return DUR(ARG0) / int64_t( INT(ARG1) ); )
239FUNC( eqDUR ,
return DUR(ARG0) == DUR(ARG1); )
240FUNC( neqDUR ,
return DUR(ARG0) != DUR(ARG1); )
241FUNC( gtDUR ,
return DUR(ARG0) > DUR(ARG1); )
242FUNC( gteqDUR ,
return DUR(ARG0) >= DUR(ARG1); )
243FUNC( smDUR ,
return DUR(ARG0) < DUR(ARG1); )
244FUNC( smeqDUR ,
return DUR(ARG0) <= DUR(ARG1); )
288DOX_MARKER([DOX_EXPR_FToLiteral_2])
291DOX_MARKER([DOX_EXPR_FToLiteral_2])
299 constexpr int tableSize= 58;
300 Token functionNames[tableSize];
301 strings::util::LoadResourcedTokens( EXPRESSIONS,
"CPD", functionNames
303 Token* descriptor= functionNames;
309 { *descriptor++, TOINT(1) }, { *descriptor++, TOINT( 2) }, { *descriptor++, TOINT( 3) }, { *descriptor++, TOINT( 4) },
310 { *descriptor++, TOINT(5) }, { *descriptor++, TOINT( 6) }, { *descriptor++, TOINT( 7) }, { *descriptor++, TOINT( 8) },
311 { *descriptor++, TOINT(9) }, { *descriptor++, TOINT(10) }, { *descriptor++, TOINT(11) }, { *descriptor++, TOINT(12) },
314 { *descriptor++, TOINT(0) }, { *descriptor++, TOINT(1) }, { *descriptor++, TOINT(2) }, { *descriptor++, TOINT( 3) },
315 { *descriptor++, TOINT(4) }, { *descriptor++, TOINT(5) }, { *descriptor++, TOINT(6) },
321DOX_MARKER([DOX_EXPR_FToLiteral_1])
323DOX_MARKER([DOX_EXPR_FToLiteral_1])
375 AddOperators( binaryOpTableDateTime );
378 "Descriptor table size mismatch: Consumed {} descriptors, {} available.",
379 descriptor - functionNames, tableSize )
392#undef BIN_ALIAS_ENTRY
int Hour
The calendar hour (0..23).
ALIB_DLL DateTime Get(lang::Timezone timezone=lang::Timezone::Local) const
#define CALCULUS_CALLBACK(func)
#define CALCULUS_SIGNATURE(BoxPointerArray)
#define ALIB_ASSERT_ERROR(cond, domain,...)
void BootstrapRegister(typename TFDecl::Signature function)
@ Local
Denotes local time.
@ UTC
Denotes UTC (coordinated universal time).
strings::util::Token Token
Type alias in namespace alib.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
time::DateTime DateTime
Type alias in namespace alib.
strings::TString< nchar > NString
Type alias in namespace alib.
strings::util::CalendarDateTime CalendarDateTime
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
expressions::Compiler Compiler
Type alias in namespace alib.
static ALIB_DLL Box Duration
Sample type-box for values of type DateTime::Duration).
static ALIB_DLL Box Integer
Sample type-box for integer types. (Precisely for type integer.)
static ALIB_DLL Box Boolean
Sample type-box for C++ type bool.
static ALIB_DLL Box Float
Sample type-box for C++ type double.
static ALIB_DLL Box DateTime
Sample type-box for date and time values of type DateTime).
static constexpr CTInvokable CTI
const std::tuple< String, Type, Type, CallbackDecl, Type, CTInvokable > OperatorTableEntry
static ALIB_DLL void Bootstrap()
ALIB_DLL DateAndTime(Compiler &compiler)