Esempio n. 1
0
TDateTime SystemTimeToDateTime(const SYSTEMTIME & SystemTime)
{
  TDateTime Result(0.0);
  Result = ComposeDateTime(EncodeDate(SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay),
    EncodeTime(SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond, SystemTime.wMilliseconds));
  return Result;
}
Esempio n. 2
0
BOOL ReadRTCClockToSyncSys(TTime *tm)
{
    int fd, retval=0;
    time_t newtime;
    struct timeval tv;
    struct timezone tz;	

    DBPRINTF("before GetExternelRTC  weekday = %d,gCurTime=%d-%d-%d,%d:%d:%d\n",tm->tm_wday,tm->tm_year,tm->tm_mon,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
	GetExternelRTC(tm);

    DBPRINTF("after GetExternelRTC weekday = %d,gCurTime= %d-%d-%d,%d:%d:%d\n",tm->tm_wday,tm->tm_year,tm->tm_mon,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
/*	 tm->tm_year= 110;
	tm->tm_mon = 1;
	tm->tm_mday= 6;
	tm->tm_hour = 13;
	tm->tm_min = 45;
	tm->tm_sec = 20;    
*/

    DBPRINTF("RetVal=%d Year=%d Month=%d Day=%d Hour=%d Min=%d Sec=%d\n", 
	     retval, tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);    
    if(((tm->tm_year<=70)||(tm->tm_year>=137))||
       ((tm->tm_mon>=12)||(tm->tm_mon<0))||
       ((tm->tm_mday<=0)||(tm->tm_mday>=32))||
       ((tm->tm_hour<0)||(tm->tm_hour>=24))||
       ((tm->tm_min<0)||(tm->tm_min>=60))||
       ((tm->tm_sec<0)||(tm->tm_sec>=60)))
	    retval=-1;
    //Fixed RTC time 
    if((tm->tm_year<=70)||(tm->tm_year>=137)) tm->tm_year=100;
    if((tm->tm_mon>=12)||(tm->tm_mon<0)) tm->tm_mon=0;
    if((tm->tm_mday<=0)||(tm->tm_mday>=32)) tm->tm_mday=1;
    if((tm->tm_hour<0)||(tm->tm_hour>=24)) tm->tm_hour=0;
    if((tm->tm_min<0)||(tm->tm_min>=60)) tm->tm_min=0;
    if((tm->tm_sec<0)||(tm->tm_sec>=60)) tm->tm_sec=0;
#ifndef ZEM500
    if(retval==-1)
    {
	retval=ioctl(fd, RTC_SET_TIME, tm);
    }
    close(fd);
#endif

    tm->tm_isdst=-1;          //don't know whether it's dst   夏令时
    //EncodeTime标准函数mktime
    //mktime可以修正tm_wday, tm_yday的值位于正确范围
    newtime=EncodeTime(tm);
    
    gettimeofday(&tv, &tz);
    
    tv.tv_sec = newtime+1;
    tv.tv_usec = 0;
    
    settimeofday(&tv, &tz);
//    settimeofday(&tv, &tz);
  
  return (retval==0);

}
Esempio n. 3
0
//---------------------------------------------------------------------------
TDateTime Now()
{
  TDateTime Result(0.0);
  SYSTEMTIME SystemTime;
  ::GetLocalTime(&SystemTime);
  Result = EncodeDate(SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay) +
    EncodeTime(SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond, SystemTime.wMilliseconds);
  return Result;
}
Esempio n. 4
0
//---------------------------------------------------------------------------
void __fastcall TDealMistakeForm::FormShow(TObject *Sender)
{
	cxDateEdit1->Date = Date();
	TDateTime ti = Time();
	unsigned short hr;
	unsigned short me;
	unsigned short sd;
	unsigned short md;
	if(hr >= 23);
		hr = 22;
	DecodeTime(ti,hr,me,sd,md);

	cxTimeEdit1->Time = ti;
	hr = (hr+1)%24;
	cxTimeEdit2->Time = EncodeTime(hr,me,sd,md);

	DataGridDBTV->ClearItems();
	TcxGridDBColumn* KHCol = DataGridDBTV->CreateColumn();
	TcxGridDBColumn* BHCol = DataGridDBTV->CreateColumn();
	TcxGridDBColumn* SFYECol = DataGridDBTV->CreateColumn();
	TcxGridDBColumn* SFRQCol = DataGridDBTV->CreateColumn();
	TcxGridDBColumn* JHCol = DataGridDBTV->CreateColumn();

	KHCol->Caption = "卡号";
//	KHCol->MinWidth = 90;
	KHCol->DataBinding->FieldName = "KH";

	BHCol->Caption = "编号";
	BHCol->DataBinding->FieldName = "BH";

	SFYECol->Caption = "消费金额";
	SFYECol->DataBinding->FieldName = "SFJE";

	SFRQCol->Caption = "消费日期";
	SFRQCol->DataBinding->FieldName = "SFRQ";

	JHCol->Caption = "消费机号";
	JHCol->DataBinding->FieldName = "JYNO";
}
Esempio n. 5
0
static int GetIDX2List(int count)
{
	pSmsIdx tmpsid;
	pSmsIdx tpsid;
	TSms tsms;
	int tcount=0;

	pSID = (pSmsIdx)MALLOC(sizeof(TSMSIDX)); //create head node.
	memset(pSID,0,sizeof(TSMSIDX));
	tpsid=pSID;

	if(FDB_InitSmsPoint())
	{
		printf("init fdsms point\n");
		while(FDB_ReadSms(&tsms))
		{
			if(tsms.ID && (tsms.Tag==UDATA_TAG_ALL) && (!IsValidTimeDuration(EncodeTime(&gCurTime), &tsms)))
			{
				tmpsid = (pSmsIdx)MALLOC(sizeof(TSMSIDX));
				memset(tmpsid,0,sizeof(TSMSIDX));
				tmpsid->smsPIN = tsms.ID;
				tmpsid->ID = ++tcount;
				tmpsid->next=NULL;

				tpsid->next = tmpsid;
				tpsid = tmpsid;
			}
		}
	}

	if(tcount==count)
		return 1;
	else
	{
		freeList();
		return 0;
	}
}