📄 conflict.c
字号:
/* Welcome to DVD Recorder-X System */
#include "time.c"
#ifndef _CONFLICT_
#define _CONFLICT_
void error(int x);
void timeDeal(Item *p);
int time_overlap(Item *p1, Item *p2);
int diserror();
/*******************************************************************************
No: 1
Name: over_lap
Function: check the conflict
检测冲突
Input: none
Output: none
*******************************************************************************/
int over_lap(long x1,long y1,long x2,long y2)
{
if((x1>=x2&&x1>=y2)||(y1<=x2&&y1<=y2))
return 0;
else
return 1;
}
int time_overlap(Item *p1, Item *p2)
{
long m=0,n=0,i,j;
long x1,x2,x3,len1,len2;
x1=calculateTime(p1);/*日期+时间 -> 秒数*/
if((p1->scflag==1)&&(p1->starttime.hour>p2->endtime.hour))
len1=calculateTime2(p1)-x1;/*预约所持续的时间长度*/
else
len1=calculateTime3(p1)-x1;/*预约所持续的时间长度*/
if((p1->scflag==1)&&(p1->starttime.hour<=p1->endtime.hour))
{m=caldays(p1->startdate, p1->enddate);}/*预约天数,可以等于0 对于单预约而言*/
else
{m=0;}/*预约天数,可以等于1 对于连续预约而言*/
x2=calculateTime(p2);/*日期+时间 -> 秒数*/
if((p2->scflag==1)&&(p2->starttime.hour>p2->endtime.hour))
len2=calculateTime2(p2)-x2;/*预约所持续的时间长度*/
else
len2=calculateTime3(p2)-x2;/*预约所持续的时间长度*/
if((p2->scflag==1)&&(p2->starttime.hour<=p2->endtime.hour))
{n=caldays(p2->startdate, p2->enddate);}/*预约天数,可以等于1 对于连续隶预约而言*/
else
{n=0;}/*预约天数,可以等于1 对于单预约*/
for(i=0;i<=n;i++,x2+=24L*60*60)
{ for(j=0,x3=x1;j<=m;j++,x3+=24L*60*60)
{
if(over_lap(x3,x3+len1,x2,x2+len2))
return 1;
}
}
return 0;
}
/*******************************************************************************
No: 2
Name: error
Function: check the error book and modify
检测预约和修改的错误
Input: none
Output: none
*******************************************************************************/
void error(int x)
{
long i;
Item *r,*s;
long teststime,testftime;
r=&newitem;
s=item;
/*teststime=item[x].startsecs;
testftime=item[x].endsecs; */
teststime=calculateTime(r);
testftime=calculateTime2(r);
errortype=0;
if(teststime>=testftime) {errortype=1;return;} /* 起始时间若小于结束时间返回错误*/
if(teststime<calseconds(Systemtime)||testftime<calseconds(Systemtime)||r->startdate.year>2020){errortype=2;return;}/*时间小于当前时间或者大于2020年返回错误*/
for(s=item;s<item+length;s++)
{
if((bmflag==0)&&(s==item+length-Button[6])) /*如果是修改*/
{
s++;
}
if(time_overlap(r,s)==1)
{errortype=3;return;}
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -