Esempio n. 1
0
int
clip_COMPLEMENT(ClipMachine * ClipMachineMemory)
{
   int len, dec;

   long d1, d2;

   int t = _clip_parinfo(ClipMachineMemory, 1);

   switch (t)
   {
   case LOGICAL_type_of_ClipVarType:
      _clip_retl(ClipMachineMemory, _clip_parl(ClipMachineMemory, 1));
      break;
   case NUMERIC_type_of_ClipVarType:
      _clip_parp(ClipMachineMemory, 1, &len, &dec);
      _clip_retndp(ClipMachineMemory, 0.00 - _clip_parnd(ClipMachineMemory, 1), len, dec);
      break;
   case CHARACTER_type_of_ClipVarType:
      clip_CHARNOT(ClipMachineMemory);
      break;
   case DATE_type_of_ClipVarType:
      d1 = _clip_jdate(1, 1, 3000);
      d2 = _clip_pardj(ClipMachineMemory, 1);
      if (d2 == 0)
	 _clip_retdj(ClipMachineMemory, d1);
      else
	 _clip_retdj(ClipMachineMemory, d1 - d2 + _clip_jdate(7, 1, 0));
      break;
   }
   return 0;
}
Esempio n. 2
0
int clip_PG_IN_DATE(ClipMachine* mp){
	PG_ROWSET* rowset = (PG_ROWSET*)_clip_fetch_c_item(
		mp,_clip_parni(mp,1),_C_ITEM_TYPE_SQL);
	char* date;
	int len;

	if(!rowset){
		_clip_trap_err(mp,0,0,0,subsys,ER_NOROWSET,er_norowset);
		return 1;
	}
	if(rowset->binary){
		date = _clip_parcl(mp,2,&len);
		if(date){
			_clip_retdj(mp,*((int*)date)+2451545);	// 2451545 - julian date
		}											// for 01/01/2000
	} else {
		int m,d,y;
		date = _clip_parc(mp,2);
		if(date){
			y = atoi(date);
			m = atoi(date+5);
			d = atoi(date+8);
			_clip_retdc(mp,y,m,d);
		} else {
			_clip_retdj(mp,0);
		}
	}
	return 0;
}
Esempio n. 3
0
int
clip_SXDATE(ClipMachine * ClipMachineMemory)
{
   ClipVar *v = _clip_par(ClipMachineMemory, 1);

   ClipMachineMemory->m6_error = 0;
   switch (_clip_parinfo(ClipMachineMemory, 1))
   {
   case DATE_type_of_ClipVarType:
      _clip_retdj(ClipMachineMemory, v->ClipDateVar_d_of_ClipVar.julian_of_ClipDateVar);
      break;
   case CHARACTER_type_of_ClipVarType:
      _clip_retdj(ClipMachineMemory, _clip_str_to_date(v->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf, ClipMachineMemory->date_format, ClipMachineMemory->epoch));
      break;
   case NUMERIC_type_of_ClipVarType:
      {
	 long alf, a, b, c, d, e, r, dd, mm, yy;

	 long ju = v->ClipNumVar_n_of_ClipVar.double_of_ClipNumVar;

	 alf = (long) ((ju - 1867216.25) / 36524.25);
	 a = ju + 1L + alf - alf / 4;
	 b = a + 1524;
	 c = (long) ((b - 122.1) / 365.25);
	 d = (long) (365.25 * c);
	 e = (long) ((b - d) / 30.6001);
	 dd = b - d - (long) (30.6001 * e);
	 if (e < 14)
	    mm = e - 1;
	 else
	    mm = e - 13;
	 if (mm > 2)
	    yy = c - 4716;
	 else
	    yy = c - 4715;
	 r = _clip_jdate(dd, mm, yy);
	 _clip_retdj(ClipMachineMemory, r);
	 break;
      }
   default:
      _clip_retdj(ClipMachineMemory, 0);
      break;
   }
   return 0;
}
Esempio n. 4
0
CLIP_DLLEXPORT void
_clip_retdc(ClipMachine * ClipMachineMemory, int yy, int mm, int dd)
{
   _clip_retdj(ClipMachineMemory, _clip_jdate(dd, mm, yy));
}
Esempio n. 5
0
int
clip_JTOD(ClipMachine * ClipMachineMemory)
{
   _clip_retdj(ClipMachineMemory, _clip_parnl(ClipMachineMemory, 1));
   return 0;
}