123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- $PBExportHeader$f_oa_workremind_chkdate.srf
- global type f_oa_workremind_chkdate from function_object
- end type
- forward prototypes
- global function boolean f_oa_workremind_chkdate (string arg_parm, datetime arg_dt)
- end prototypes
- global function boolean f_oa_workremind_chkdate (string arg_parm, datetime arg_dt);//检查arg_dt是否在约定时间范围内
- //类型:
- // 一次性
- // 如果检查时间与约定时间相差 正负30秒 则视作有效
- // 循环
- // 如果
- //
- //
- boolean rslt,hasEndDate
- date date_st,date_en,date_cur,date_tar
- time time_st,time_en,time_cur,time_tar
- long second
- string WeekList
- //long fit_hour=30,fit_minute=5,fit_second=1//修正值 单位:秒
- s_oa_workremind_timetype los_time
- rslt=false
- los_time=f_oa_workremind_releasetime(arg_parm)
- date_cur=date(los_time.oncedate)
- time_cur=time(los_time.oncetime)
- date_tar=date(arg_dt)
- time_tar=time(arg_dt)
- //==================================
- //一次性提醒
- //==================================
- if los_time.checktype="once"then
- if date_tar=date_cur then
- second=SecondsAfter(time_tar,time_cur)
- if second<=30 and second>=-30 then
- rslt=true
- end if
- end if
- goto ext
- end if
- //=======================
- //循环执行提醒
- //=======================
- //日期部分比较
- hasEndDate=false
- date_st=date(mid(los_time.startdate,1,pos(los_time.startdate,";")-1))
- if mid(los_time.startdate,pos(los_time.startdate,";")+1)="noend"then
- else
- hasEndDate=true
- date_en=date(mid(los_time.startdate,pos(los_time.startdate,";")+1))
- end if
- //检测是否在日期范围内
- if hasEndDate then
- if date_tar<date_st and date_tar>date_en then
- goto ext
- end if
- else
- if date_tar<date_st then
- goto ext
- end if
- end if
- //检查日期是否为间隔时间段内第一个单位时间
- long day,baseDay
- day=DaysAfter(date_st,date_tar)
- if los_time.IntervalType="week" then
- baseDay=long(mid(los_time.interval,1,pos(los_time.interval,";")-1))*7
- string tmp_week
- tmp_week=mid(los_time.interval,pos(los_time.interval,";")+1)
- if mid(tmp_week,1,1)="1" then WeekList+="Monday,"
- if mid(tmp_week,2,1)="1" then WeekList+="Tuesday,"
- if mid(tmp_week,3,1)="1" then WeekList+="Wednesday,"
- if mid(tmp_week,4,1)="1" then WeekList+="Thursday,"
- if mid(tmp_week,5,1)="1" then WeekList+="Friday,"
- if mid(tmp_week,6,1)="1" then WeekList+="Saturday,"
- if mid(tmp_week,7,1)="1" then WeekList+="Sunday,"
- else
- baseDay=long(los_time.interval)
- end if
- day=mod(day,baseDay)
- if los_time.IntervalType="day" then
- if baseDay<>1 then
- if day<>1 then
- goto ext
- end if
- end if
- elseif los_time.IntervalType="week" then
- if day>7 or day=0 then
- if date_tar<>date_st then
- goto ext
- end if
- end if
- //具体星期几
- string a
- a=string(date_tar,"yyyy-mm-dd")
- date b
- b=date(a)
- string weekName
- weekName=DayName(b)
- if pos(WeekList,weekName)=0 then
- goto ext
- end if
- end if
- //时间部分比较
- long baseSecond
- if los_time.fretype="once" then
- time_cur=time(los_time.fre)
- else
- baseSecond=long(mid(los_time.fre,1,pos(los_time.fre,";")-1))
- string ls_time
- ls_time=mid(los_time.fre,pos(los_time.fre,";")+1)
- time_st=time(mid(ls_time,1,pos(ls_time,";")-1))
- time_en=time(mid(ls_time,pos(ls_time,";")+1))
-
- if los_time.fretype="小时" then
- baseSecond=baseSecond*60*60
- elseif los_time.fretype="分钟" then
- baseSecond=baseSecond*60
- elseif los_time.fretype="秒" then
- end if
- end if
- //确定当前时间在执行时间段内
- if los_time.fretype="once" then
- second=SecondsAfter(time_cur,time_tar)
- if second>=0 and second<=5 then
- rslt=true
- end if
- goto ext
- else
- second=SecondsAfter(time_st,time_tar)
- if time_tar<time_st or time_tar>time_en then
- goto ext
- end if
- end if
- //判断当前时间是否在第一个单位时间内
- long firstBase
- if los_time.fretype="小时" then
- firstBase=60
- elseif los_time.fretype="分钟"then
- firstBase=5
- elseif los_time.fretype="秒"then
- firstBase=1
- end if
- if mod(second,basesecond)<=firstBase then
- if mod(second,basesecond)=0 then
- if firstBase<>1 then//非秒情况;
- goto ext
- elseif second<>1 then//非第一秒
- goto ext
- end if
- end if
- rslt=true
- goto ext
- end if
- ext:
- return rslt
- end function
|