4#define ARG1 (*(args+1))
5#define INT(box) (box).Unbox<integer >()
6#define FLT(box) (box).Unbox<double >()
7#define DT(box) (box).Unbox<DateTime >()
8#define DUR(box) (box).Unbox<DateTime::Duration>()
9#define FUNC( name,...) Box name( Scope& scope, \
12 { (void) scope; (void) args; (void) end; __VA_ARGS__ }
14#if !ALIB_FEAT_BOXING_BIJECTIVE_INTEGRALS
15# define TOINT(arg) arg
17# define TOINT(arg) integer(arg)
28DOX_MARKER([DOX_EXPR_FToLiteral_3])
29void FToLiteral_Duration(
const Box& constantValue,
AString& expressionString ) {
31 auto value= constantValue.Unbox<DateTime::Duration>().InNanoseconds();
36 result=
"Milliseconds";
38 result=
"Nanoseconds";
40 if( (value % 1000) == 0 ) {
42 result=
"Microseconds";
43 if( (value % 1000) == 0 ) {
45 result=
"Milliseconds";
46 if( (value % 1000) == 0 ) {
49 if( (value % 60) == 0 ) {
52 if( (value % 60) == 0 ) {
55 if( (value % 24) == 0 ) {
61 expressionString << result <<
'(' << value <<
')' ;
63DOX_MARKER([DOX_EXPR_FToLiteral_3])
65void FToLiteral_DateTime(
const Box& constantValue,
AString& expressionString ) {
68 expressionString <<
"UTCDateTime( " << ct.Year <<
','
74 << ct.Millisecond <<
')' ;
81FUNC( dateTime ,
auto qtyArgs= end-args;
83 ( qtyArgs> 1 ) ?
int( INT(*(args+1)) ) : 1,
84 ( qtyArgs> 2 ) ?
int( INT(*(args+2)) ) : 1,
85 ( qtyArgs> 3 ) ?
int( INT(*(args+3)) ) : 0,
86 ( qtyArgs> 4 ) ?
int( INT(*(args+4)) ) : 0,
87 ( qtyArgs> 5 ) ?
int( INT(*(args+5)) ) : 0,
88 ( qtyArgs> 6 ) ?
int( INT(*(args+6)) ) : 0
93FUNC( utcDateTime ,
auto qtyArgs= end-args;
95 ( qtyArgs> 1 ) ?
int( INT(*(args+1)) ) : 1,
96 ( qtyArgs> 2 ) ?
int( INT(*(args+2)) ) : 1,
97 ( qtyArgs> 3 ) ?
int( INT(*(args+3)) ) : 0,
98 ( qtyArgs> 4 ) ?
int( INT(*(args+4)) ) : 0,
99 ( qtyArgs> 5 ) ?
int( INT(*(args+5)) ) : 0,
100 ( qtyArgs> 6 ) ?
int( INT(*(args+6)) ) : 0
106 ct.
Hour= ct.Minute= ct.Second= ct.Millisecond= 0;
109 ct.
Hour= ct.Minute= ct.Second= ct.Millisecond= 0;
112FUNC( age ,
return DT(ARG0).Age(); )
113FUNC( isOlderThan ,
return DT(ARG0).IsOlderThan( DUR(ARG1) ); )
136FUNC( nanosecondsInt ,
return DateTime::Duration::FromNanoseconds ( INT(ARG0) ); )
138FUNC( microsecondsInt ,
return DateTime::Duration::FromAbsoluteMicroseconds ( INT(ARG0) ); )
139FUNC( millisecondsInt ,
return DateTime::Duration::FromAbsoluteMilliseconds ( INT(ARG0) ); )
140FUNC( secondsInt ,
return DateTime::Duration::FromAbsoluteSeconds ( INT(ARG0) ); )
141FUNC( minutesInt ,
return DateTime::Duration::FromAbsoluteMinutes ( INT(ARG0) ); )
142FUNC( hoursInt ,
return DateTime::Duration::FromAbsoluteHours ( INT(ARG0) ); )
143FUNC( daysInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) ); )
144FUNC( weeksInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) * 7 ); )
145FUNC( monthsInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) * 30 ); )
146FUNC( yearsInt ,
return DateTime::Duration::FromAbsoluteDays ( INT(ARG0) * 365 ); )
148FUNC( microsecondsFlt ,
return DateTime::Duration::FromMicroseconds ( FLT(ARG0) ); )
149FUNC( millisecondsFlt ,
return DateTime::Duration::FromMilliseconds ( FLT(ARG0) ); )
150FUNC( secondsFlt ,
return DateTime::Duration::FromSeconds ( FLT(ARG0) ); )
151FUNC( minutesFlt ,
return DateTime::Duration::FromMinutes ( FLT(ARG0) ); )
152FUNC( hoursFlt ,
return DateTime::Duration::FromHours ( FLT(ARG0) ); )
153FUNC( daysFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) ); )
154FUNC( weeksFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) * 7.0 ); )
155FUNC( monthsFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) * 30.0 ); )
156FUNC( yearsFlt ,
return DateTime::Duration::FromDays ( FLT(ARG0) * 365.0 ); )
160FUNC( inDays ,
return DUR(ARG0).InDays (); )
161FUNC( inHours ,
return DUR(ARG0).InHours (); )
162FUNC( inMinutes ,
return DUR(ARG0).InMinutes (); )
163FUNC( inSeconds ,
return DUR(ARG0).InSeconds (); )
164FUNC( inMilliseconds ,
return DUR(ARG0).InMilliseconds(); )
165FUNC( inMicroseconds ,
return DUR(ARG0).InMicroseconds(); )
166FUNC( inNanoseconds ,
return DUR(ARG0).InNanoseconds (); )
167FUNC( inHertz ,
return DUR(ARG0).InHertz(2); )
170FUNC( add_DTDUR ,
return DT(ARG0) + DUR(ARG1); )
171FUNC( add_DURDT ,
return DT(ARG1) + DUR(ARG0); )
172FUNC( sub_DTDUR ,
return DT(ARG0) - DUR(ARG1); )
173FUNC( sub_DTDT ,
return DT(ARG0) - DT(ARG1); )
174FUNC( eqDT ,
return DT(ARG0) == DT(ARG1); )
175FUNC( neqDT ,
return DT(ARG0) != DT(ARG1); )
176FUNC( gtDT ,
return DT(ARG0) > DT(ARG1); )
177FUNC( gteqDT ,
return DT(ARG0) >= DT(ARG1); )
178FUNC( smDT ,
return DT(ARG0) < DT(ARG1); )
179FUNC( smeqDT ,
return DT(ARG0) <= DT(ARG1); )
183FUNC( add_DURDUR ,
return DUR(ARG0) + DUR(ARG1); )
184FUNC( sub_DURDUR ,
return DUR(ARG0) - DUR(ARG1); )
185FUNC( mul_DURF ,
return DUR(ARG0) * FLT(ARG1); )
186FUNC( mul_FDUR ,
return DUR(ARG1) * FLT(ARG0); )
187FUNC( mul_DURI ,
return DUR(ARG0) * int64_t( INT(ARG1) ); )
188FUNC( mul_IDUR ,
return DUR(ARG1) * int64_t( INT(ARG0) ); )
189FUNC( div_DURF ,
return DUR(ARG0) / FLT(ARG1); )
190FUNC( div_DURI ,
return DUR(ARG0) / int64_t( INT(ARG1) ); )
192FUNC( eqDUR ,
return DUR(ARG0) == DUR(ARG1); )
193FUNC( neqDUR ,
return DUR(ARG0) != DUR(ARG1); )
194FUNC( gtDUR ,
return DUR(ARG0) > DUR(ARG1); )
195FUNC( gteqDUR ,
return DUR(ARG0) >= DUR(ARG1); )
196FUNC( smDUR ,
return DUR(ARG0) < DUR(ARG1); )
197FUNC( smeqDUR ,
return DUR(ARG0) <= DUR(ARG1); )
240DOX_MARKER([DOX_EXPR_FToLiteral_2])
243DOX_MARKER([DOX_EXPR_FToLiteral_2])
250 constexpr int tableSize= 58;
251 Token functionNames[tableSize];
252 strings::util::LoadResourcedTokens( EXPRESSIONS,
"CPD", functionNames
254 Token* descriptor= functionNames;
260 { *descriptor++, TOINT(1) }, { *descriptor++, TOINT( 2) }, { *descriptor++, TOINT( 3) }, { *descriptor++, TOINT( 4) },
261 { *descriptor++, TOINT(5) }, { *descriptor++, TOINT( 6) }, { *descriptor++, TOINT( 7) }, { *descriptor++, TOINT( 8) },
262 { *descriptor++, TOINT(9) }, { *descriptor++, TOINT(10) }, { *descriptor++, TOINT(11) }, { *descriptor++, TOINT(12) },
265 { *descriptor++, TOINT(0) }, { *descriptor++, TOINT(1) }, { *descriptor++, TOINT(2) }, { *descriptor++, TOINT( 3) },
266 { *descriptor++, TOINT(4) }, { *descriptor++, TOINT(5) }, { *descriptor++, TOINT(6) },
272DOX_MARKER([DOX_EXPR_FToLiteral_1])
274DOX_MARKER([DOX_EXPR_FToLiteral_1])
326 AddOperators( binaryOpTableDateTime );
329 "Descriptor table size mismatch: Consumed {} descriptors, {} available.",
330 descriptor - functionNames, tableSize )
343#undef BIN_ALIAS_ENTRY
#define ALIB_ASSERT_ERROR(cond, domain,...)
int Hour
The calendar hour (0..23).
DateTime Get(lang::Timezone timezone=lang::Timezone::Local) const
#define CALCULUS_CALLBACK(func)
#define CALCULUS_SIGNATURE(BoxPointerArray)
void BootstrapRegister(typename TFDecl::Signature function)
@ Local
Denotes local time.
@ UTC
Denotes UTC (coordinated universal time).
strings::TString< nchar > NString
Type alias in namespace #"%alib".
boxing::Box Box
Type alias in namespace #"%alib".
expressions::Compiler Compiler
Type alias in namespace #"%alib".
strings::util::CalendarDateTime CalendarDateTime
Type alias in namespace #"%alib".
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
strings::util::Token Token
Type alias in namespace #"%alib".
time::DateTime DateTime
Type alias in namespace #"%alib".
static Box Integer
Sample type-box for integer types. (Precisely for type #"lang::integer".).
static Box Boolean
Sample type-box for C++ type bool.
static Box Float
Sample type-box for C++ type double.
static Box DateTime
Sample type-box for date and time values of type #"time::DateTime").
const std::tuple< String, Type, Type, CallbackDecl, Type, CTInvokable > OperatorTableEntry
static constexpr CTInvokable CTI
DateAndTime(Compiler &compiler)