一个自己封装的日期时间操作的用户对象

类别:数据库 点击:0 评论:0 推荐:

$PBExportHeader$nvo_datetime.sru $PBExportComments$日期时间操作类 forward global type nvo_datetime from nonvisualobject end type type stc_systemtime from structure within nvo_datetime end type end forward type stc_systemtime from structure integer wyear integer wmonth integer wdayofweek integer wday integer whour integer wminute integer wsecond integer wmilliseconds end type global type nvo_datetime from nonvisualobject autoinstantiate end type type prototypes Function long SetSystemTime(stc_systemtime lpSystemTime) Library "kernel32.dll" end prototypes forward prototypes public function integer of_getdaysinmonth (date ad_date) public function date of_getlastdayinmonth (date ad_date) public function date of_getlastdayinmonth (integer ai_year, integer ai_month) public function date of_getfirstdayinmonth (date ad_date) public function date of_getfirstdayinmonth (integer ai_year, integer ai_month) public function boolean of_isleapyear (date ad_date) public function boolean of_isleapyear (integer ai_year) public function boolean of_lsweekend (date ad_date) public function date of_skipholidays (date ad_date, integer ai_increment) public function date of_getnextworkday (datawindow adw_holidays, string as_columnname, date ad_date) public function date of_getpreviousworkday (datawindow adw_holidays, string as_columnname, date ad_date) public function date of_getpreviousworkday (date ad_date) public function date of_getnextworkday (date ad_date) public function date of_skipholidays (datastore ads_holidays, string as_columnname, date ad_date, integer ai_increment) public function date of_skipholidays (datawindow adw_holidays, string as_columnname, date ad_date, integer ai_increment) public function date of_getnextworkday (datastore ads_holidays, string as_columnname, date ad_date) public function date of_getfirstworkday (datawindow adw_holidays, string as_columnname, date ad_date) public function date of_getfirstworkday (datastore ads_holidays, string as_columnname, date ad_date) public function date of_getpreviousworkday (datastore ads_holidays, string as_columnname, date ad_date) public function date of_getfirstworkday (date ad_date) public function date of_getlastworkday (datastore ads_holidays, string as_columnname, date ad_date) public function date of_getlastworkday (datawindow adw_holidays, string as_columnname, date ad_date) public function date of_getlastworkday (date ad_date) public function integer of_getdaysinmonth () public function integer of_countdowinmonth (date ad_date, integer ai_dow) public function integer of_countdowinmonth (date ad_date) public function integer of_countworkdays (datawindow adw_holidays, string as_columnname, date ad_startdate, date ad_enddate) public function date of_getfirstdayinweek (date ad_date) public function date of_getlastdayinweek (date ad_date) public function date of_getfirstdayinmonth () public function date of_getlastdayinmonth () public function date of_getfirstworkday () public function date of_getlastworkday () public function date of_getfirstdayinweek () public function date of_getlastdayinweek () public function date of_getnextworkday () public function date of_getpreviousworkday () public function integer of_countholidays (datawindow adw_holidays, string as_columnname, date ad_startdate, date ad_enddate) public function integer of_countholidays (date ad_startdate, date ad_enddate) public function integer of_countholidays (datastore ads_holidays, string as_columnname, date ad_startdate, date ad_enddate) public function integer of_countworkdays (datastore ads_holidays, string as_columnname, date ad_startdate, date ad_enddate) public function integer of_countworkdays (date ad_startdate, date ad_enddate) public function integer of_getage (date ad_brithday, date ad_date) public function long of_yearsafter (date ad_start, date ad_end) public function long of_monthsafter (date ad_start, date ad_end) public function long of_weeksafter (date ad_start, date ad_end) public function long of_secondsafter (datetime adtm_start, datetime adtm_end) public function long of_millisecsafter (time atm_start, time atm_end) public function date of_relativemonth (date ad_source, integer al_month) public function datetime of_relativedatetime (datetime adtm_start, integer al_offset) public function integer of_getquarter (date ad_source) public function integer of_getquarter () public function date of_getfirstdayinquarter (date ad_date) public function date of_getfirstdayinquarter () public function date of_getlastdayinquarter (date ad_date) public function date of_getlastdayinquarter () public function long of_countweeksinyear (date ad_source) public function integer of_getdayinweek (date ad_source) public function date of_getfirstdayinyear (date ad_date) public function date of_getfirstdayinyear () public function date of_getfirstdayinyear (integer ai_year) public function date of_getlastdayinyear (date ad_date) public function date of_getlastdayinyear () public function date of_getlastdayinyear (integer ai_year) public function integer of_countyeardays (date ad_date) public function integer of_countyeardays () public function integer of_countyeardays (integer ai_year) public function string of_getconstellation (date ad_date) public function string of_getgenus (integer ai_year) public function string of_convertdayoflunar (date ad_date) public function datetime of_relativedatetime (datetime ad_datetime, long al_number, string as_kind) public function string of_gettgdz (integer ai_year) public function string of_gettgdz (date ad_date) public function string of_gettgdz () public function boolean of_isleapyear () public function string of_getgenus (date ad_date) public function string of_getgenus () public function integer of_countdowinmonth () public function integer of_getage (date ad_brithday) public function integer of_countdowinmonth (integer ai_dow) public function long of_countweeksinyear () public function boolean of_setsystemtime (datetime adt_datetime) end prototypes public function integer of_getdaysinmonth (date ad_date);/*函数功能:获取指定日期所在月份的天数 返回值:integer 指定日期所在月份的天数 参数:ad_date date 日期*/ return integer(28+integer(mid('3'+string(abs(sign(mod(sign(mod(abs(year(ad_date)),4))+sign(mod(abs(year(ad_date)),100))+sign(mod(abs(year(ad_date)),400)),2)) -1))+'3232332323',month(ad_date),1))) end function public function date of_getlastdayinmonth (date ad_date);/*函数功能:获取指定日期所在月份的最后一天 返回值:date 指定日期所在月份的最后一天 参数:ad_date date 日期*/ return date(year(ad_date),month(ad_date),integer(28+integer(mid('3'+string(abs(sign(mod(sign(mod(abs(year(ad_date)),4))+sign(mod(abs(year(ad_date)),100))+sign(mod(abs(year(ad_date)),400)),2)) -1))+'3232332323',month(ad_date),1)))) end function public function date of_getlastdayinmonth (integer ai_year, integer ai_month);/*函数功能:获取指定年份,月份的最后一天 返回值:date 指定年份,月份的最后一天 参数:integer ai_year 年份 integer ai_month 月份*/ date ld_date ld_date=date(ai_year,ai_month,1) return date(year(ld_date),month(ld_date),integer(28+integer(mid('3'+string(abs(sign(mod(sign(mod(abs(year(ld_date)),4))+sign(mod(abs(year(ld_date)),100))+sign(mod(abs(year(ld_date)),400)),2)) -1))+'3232332323',month(ld_date),1)))) end function public function date of_getfirstdayinmonth (date ad_date);/*函数功能:获取指定日期所在月份的第一天 返回值:date 指定日期所在月份的第一天 参数:date ad_date 日期 */ return date(year(ad_date),month(ad_date),1) end function public function date of_getfirstdayinmonth (integer ai_year, integer ai_month);/*函数功能:获取指定年份,月份的第一天 返回值:date 指定年份,月份的第一天 参数:integer ai_year 年份 integer ai_month 月份*/ return date(ai_year,ai_month,1) end function public function boolean of_isleapyear (date ad_date);/*函数功能:获取指定日期所在年份是否为闰年 返回值:boolean 指定日期所在年份是否为闰年,true为是闰年,false为平年 参数:ad_date date 日期*/ integer li_year li_year=year(ad_date) return abs(sign(mod(sign(mod(abs(li_year),4))+sign(mod(abs(li_year),100))+sign(mod(abs(li_year),400)),2)) -1)=1 end function public function boolean of_isleapyear (integer ai_year);/*函数功能:获取指定年份是否为闰年 返回值:boolean 指定年份是否为闰年,true为是闰年,false为平年 参数:ai_year integer 年份*/ return abs(sign(mod(sign(mod(abs(ai_year),4))+sign(mod(abs(ai_year),100))+sign(mod(abs(ai_year),400)),2)) -1)=1 end function public function boolean of_lsweekend (date ad_date);/*函数功能:获取指定日期是否为周末 返回值:date 指定日期是否为周末 参数:ad_date date 日期*/ string ls_week ls_week=dayname(ad_date) choose case dayname(ad_date) case "Saturday","Sunday" return true case else return false end choose end function public function date of_skipholidays (date ad_date, integer ai_increment);/*函数功能:获取指定日期跳过周末的下一个日期 返回值:date 返回指定的指定日期跳过周末的下一个日期 参数:ad_date date 日期 ai_increment integer 指定的跳过天数 */ date ld_date ld_date=ad_date do while of_lsweekend(ld_date)=true ld_date=RelativeDate ( ld_date, ai_increment ) loop return ld_date end function public function date of_getnextworkday (datawindow adw_holidays, string as_columnname, date ad_date);/*函数功能:获取指定日期跳过周末和节假日的下一个工作日 返回值:date 返回指定的指定日期跳过周末的下一个工作日 参数:adw_holidays datawindow存储指定节假日的数据窗口 as_columnname string 数据窗口中存储节假日的列名 ad_date date 日期 */ return of_skipholidays(adw_holidays,as_columnname,RelativeDate (ad_date,1),1) end function public function date of_getpreviousworkday (datawindow adw_holidays, string as_columnname, date ad_date);/*函数功能:获取指定日期跳过周末和节假日的上一个工作日 返回值:date 返回指定的指定日期跳过周末的上一个工作日 参数:adw_holidays datawindow存储指定节假日的数据窗口 as_columnname string 数据窗口中存储节假日的列名 ad_date date 日期 */ return of_skipholidays(adw_holidays,as_columnname,RelativeDate (ad_date,-1),-1) end function public function date of_getpreviousworkday (date ad_date);/*函数功能:获取指定日期跳过周末的上一个工作日 返回值:date 返回指定的指定日期跳过周末的上一个工作日 参数: ad_date date 日期 */ return of_skipholidays(RelativeDate (ad_date,-1),-1) end function public function date of_getnextworkday (date ad_date);/*函数功能:获取指定日期跳过周末的下一个工作日 返回值:date 返回指定的指定日期跳过周末的下一个工作日 参数: ad_date date 日期 */ return of_skipholidays(RelativeDate (ad_date,1),1) end function public function date of_skipholidays (datastore ads_holidays, string as_columnname, date ad_date, integer ai_increment);/*函数功能:获取指定日期跳过周末和节假日的下一个日期 返回值:date 返回指定的指定日期跳过周末和节假日的下一个日期 参数:adw_holidays datastore存储指定节假日的数据存储对象 as_columnname string 数据窗口中存储节假日的列名 ad_date date 日期 ai_increment integer 指定的跳过天数 */ date ld_date ld_date=ad_date do while of_lsweekend(ld_date)=true or ads_holidays.find("string("+as_columnname+",'yyyy-mm-dd')"+"='"+string(ld_date,"yyyy-mm-dd")+"'",1,ads_holidays.rowcount())<>0 ld_date=RelativeDate ( ld_date, ai_increment ) loop return ld_date end function public function date of_skipholidays (datawindow adw_holidays, string as_columnname, date ad_date, integer ai_increment);/*函数功能:获取指定日期跳过周末和节假日的下一个日期 返回值:date 返回指定的指定日期跳过周末和节假日的下一个日期 参数:adw_holidays datawindow存储指定节假日的数据窗口 as_columnname string 数据窗口中存储节假日的列名 ad_date date 日期 ai_increment integer 指定的跳过天数 */ date ld_date ld_date=ad_date do while of_lsweekend(ld_date)=true or adw_holidays.find("string("+as_columnname+",'yyyy-mm-dd')"+"='"+string(ld_date,"yyyy-mm-dd")+"'",1,adw_holidays.rowcount())<>0 ld_date=RelativeDate ( ld_date, ai_increment ) loop return ld_date end function public function date of_getnextworkday (datastore ads_holidays, string as_columnname, date ad_date);/*函数功能:获取指定日期跳过周末和节假日的下一个工作日 返回值:date 返回指定的指定日期跳过周末的下一个工作日 参数:ads_holidays datastore存储指定节假日的数据存储对象 as_columnname string 数据窗口中存储节假日的列名 ad_date date 日期 */ return of_skipholidays(ads_holidays,as_columnname,RelativeDate (ad_date,1),1) end function public function date of_getfirstworkday (datawindow adw_holidays, string as_columnname, date ad_date);/*函数功能:获取指定日期所在月的第一个工作日 返回值:date 返回指定日期所在月的第一个工作日 参数:adw_holidays datawindow存储指定节假日的数据存储对象 as_columnname string 数据窗口中存储节假日的列名 ad_date date 日期 */ date d_temp d_temp=date(year(ad_date),month(ad_date),1) return of_skipholidays(adw_holidays,as_columnname,d_temp,1) end function public function date of_getfirstworkday (datastore ads_holidays, string as_columnname, date ad_date);/*函数功能:获取指定日期所在月的第一个工作日 返回值:date 返回指定日期所在月的第一个工作日 参数:ads_holidays datastore存储指定节假日的数据存储对象 as_columnname string 数据窗口中存储节假日的列名 ad_date date 日期 */ date d_temp d_temp=date(year(ad_date),month(ad_date),1) return of_skipholidays(ads_holidays,as_columnname,d_temp,1) end function public function date of_getpreviousworkday (datastore ads_holidays, string as_columnname, date ad_date);/*函数功能:获取指定日期跳过周末和节假日的上一个工作日 返回值:date 返回指定的指定日期跳过周末的上一个工作日 参数:ads_holidays datastore存储指定节假日的数据存储对象 as_columnname string 数据窗口中存储节假日的列名 ad_date date 日期 */ return of_skipholidays(ads_holidays,as_columnname,RelativeDate (ad_date,-1),-1) end function public function date of_getfirstworkday (date ad_date);/*函数功能:获取指定日期所在月的第一个工作日 返回值:date 返回指定日期所在月的第一个工作日 参数: ad_date date 日期 */ date d_temp d_temp=date(year(ad_date),month(ad_date),1) return of_skipholidays(d_temp,1) end function public function date of_getlastworkday (datastore ads_holidays, string as_columnname, date ad_date);/*函数功能:获取指定日期所在月的最后一个工作日 返回值:date 返回指定日期所在月的最后一个工作日 参数:ads_holidays datastore存储指定节假日的数据存储对象 as_columnname string 数据窗口中存储节假日的列名 ad_date date 日期 */ date d_temp d_temp=of_getlastdayinmonth(ad_date) return of_skipholidays(ads_holidays,as_columnname,d_temp,-1) end function public function date of_getlastworkday (datawindow adw_holidays, string as_columnname, date ad_date);/*函数功能:获取指定日期所在月的最后一个工作日 返回值:date 返回指定日期所在月的最后一个工作日 参数:adw_holidays datawindow存储指定节假日的数据窗口 as_columnname string 数据窗口中存储节假日的列名 ad_date date 日期 */ date d_temp d_temp=of_getlastdayinmonth(ad_date) return of_skipholidays(adw_holidays,as_columnname,d_temp,-1) end function public function date of_getlastworkday (date ad_date);/*函数功能:获取指定日期所在月的最后一个工作日 返回值:date 返回指定日期所在月的最后一个工作日 参数: ad_date date 日期 */ date d_temp d_temp=of_getlastdayinmonth(ad_date) return of_skipholidays(d_temp,-1) end function public function integer of_getdaysinmonth ();/*函数功能:获取指定日期所在月份的天数 返回值:integer 指定日期所在月份的天数 参数:ad_date date 日期*/ return integer(28+integer(mid('3'+string(abs(sign(mod(sign(mod(abs(year(today())),4))+sign(mod(abs(year(today())),100))+sign(mod(abs(year(today())),400)),2)) -1))+'3232332323',month(today()),1))) end function public function integer of_countdowinmonth (date ad_date, integer ai_dow);/*函数功能:获取指定日期所在月份的指定星期几的天数 返回值:integer 指定日期所在月份的指定星期几的天数 参数:ad_date date 日期 ai_dow integer 指定的星期几 1代表星期天......7代表星期六*/ date d_first integer intcount,intmonth if(ai_dow<1 or ai_dow>7) then ai_dow=daynumber(ad_date) end if intmonth=month(ad_date) d_first=date(year(ad_date),month(ad_date),1) do while daynumber(d_first)<>ai_dow d_first=relativedate(d_first,1) loop intcount=0 do while month(d_first)=intmonth intcount=intcount+1 d_first=relativedate(d_first,7) loop return intcount end function public function integer of_countdowinmonth (date ad_date);/*函数功能:获取指定日期所在月份的星期一的天数 返回值:integer 指定日期所在月份的星期一的天数 参数:ad_date date 日期*/ return of_countdowinmonth(ad_date,2) end function public function integer of_countworkdays (datawindow adw_holidays, string as_columnname, date ad_startdate, date ad_enddate);/*函数功能:获取指定日期之间的工作日天数 返回值:工作日天数 参数:adw_holidays datawindow存储指定节假日的数据窗口 as_columnname string 数据窗口中存储节假日的列名 ad_startdate date 开始日期 ad_enddate date 结束日期 */ integer intdays,li_return date d_temp integer intsubstract if ad_enddate<ad_startdate then d_temp=ad_startdate ad_enddate=ad_startdate ad_startdate=d_temp end if ad_startdate=of_skipholidays(adw_holidays,as_columnname,ad_startdate,1) ad_enddate=of_skipholidays(adw_holidays,as_columnname,ad_enddate,-1) if ad_startdate>ad_enddate then li_return=0 else intdays=DaysAfter (ad_startdate, ad_enddate )+1 intsubstract=intsubstract+of_countholidays(adw_holidays,as_columnname,ad_startdate,ad_enddate) end if li_return=intdays - intsubstract return li_return end function public function date of_getfirstdayinweek (date ad_date);/*函数功能:获取指定日期所在周的第一天 返回值:date 返回指定日期所在周的第一天 参数:ad_date date 日期 */ date ld_return ld_return=RelativeDate (ad_date, 1 - daynumber(ad_date)) return ld_return end function public function date of_getlastdayinweek (date ad_date);/*函数功能:获取指定日期所在周的最后一天 返回值:date 返回指定日期所在周的最后一天 参数:ad_date date 日期 */ date ld_return ld_return=RelativeDate (ad_date, 7 - daynumber(ad_date)) return ld_return end function public function date of_getfirstdayinmonth ();/*函数功能:获取当前日期所在月份的第一天 返回值:date 当前日期所在月份的第一天 参数:date ad_date 日期 */ return date(year(today()),month(today()),1) end function public function date of_getlastdayinmonth ();/*函数功能:获取当前日期所在月份的最后一天 返回值:date 当前日期所在月份的最后一天*/ return date(year(today()),month(today()),integer(28+integer(mid('3'+string(abs(sign(mod(sign(mod(abs(year(today())),4))+sign(mod(abs(year(today())),100))+sign(mod(abs(year(today())),400)),2)) -1))+'3232332323',month(today()),1)))) end function public function date of_getfirstworkday ();/*函数功能:获取当前日期所在月的第一个工作日 返回值:date 返回当前日期所在月的第一个工作日 */ date d_temp d_temp=date(year(today()),month(today()),1) return of_skipholidays(d_temp,1) end function public function date of_getlastworkday ();/*函数功能:获取当前日期所在月的最后一个工作日 返回值:date 返回当前日期所在月的最后一个工作日 */ date d_temp d_temp=of_getlastdayinmonth(today()) return of_skipholidays(d_temp,-1) end function public function date of_getfirstdayinweek ();/*函数功能:获取当前日期所在周的第一天 返回值:date 返回当前日期所在周的第一天 参数:ad_date date 日期 */ date ld_return ld_return=RelativeDate (today(), 1 - daynumber(today())) return ld_return end function public function date of_getlastdayinweek ();/*函数功能:获取指定日期所在周的最后一天 返回值:date 返回指定日期所在周的最后一天*/ date ld_return ld_return=RelativeDate (today(), 7 - daynumber(today())) return ld_return end function public function date of_getnextworkday ();/*函数功能:获取当前日期跳过周末的下一个工作日 返回值:date 返回当前的指定日期跳过周末的下一个工作日 */ return of_skipholidays(RelativeDate (today(),1),1) end function public function date of_getpreviousworkday ();/*函数功能:获取当前日期跳过周末的上一个工作日 返回值:date 返回当前日期跳过周末的上一个工作日 */ return of_skipholidays(RelativeDate (today(),-1),-1) end function public function integer of_countholidays (datawindow adw_holidays, string as_columnname, date ad_startdate, date ad_enddate);/*函数功能:获取指定日期之间的节假日天数 返回值:节假日天数 参数:adw_holidays datawindow存储指定节假日的数据窗口 as_columnname string 数据窗口中存储节假日的列名 ad_startdate date 开始日期 ad_enddate date 结束日期 */ integer li_return date ld_date ld_date=ad_startdate do while ld_date<=ad_enddate if of_lsweekend(ld_date)=true or adw_holidays.find("string("+as_columnname+",'yyyy-mm-dd')"+"='"+string(ld_date,"yyyy-mm-dd")+"'",1,adw_holidays.rowcount())=0 then li_return++ end if ld_date=relativedate(ld_date,1) loop return li_return end function public function integer of_countholidays (date ad_startdate, date ad_enddate);/*函数功能:获取指定日期之间的节假日天数 返回值:节假日天数 参数:ad_startdate date 开始日期 ad_enddate date 结束日期 */ integer li_return date ld_date ld_date=ad_startdate do while ld_date<=ad_enddate if of_lsweekend(ld_date)=true then li_return++ end if ld_date=relativedate(ld_date,1) loop return li_return end function public function integer of_countholidays (datastore ads_holidays, string as_columnname, date ad_startdate, date ad_enddate);/*函数功能:获取指定日期之间的节假日天数 返回值:节假日天数 参数:ads_holidays datastore存储指定节假日的数据存储对象 as_columnname string 数据窗口中存储节假日的列名 ad_startdate date 开始日期 ad_enddate date 结束日期 */ integer li_return date ld_date ld_date=ad_startdate do while ld_date<=ad_enddate if of_lsweekend(ld_date)=true or ads_holidays.find("string("+as_columnname+",'yyyy-mm-dd')"+"='"+string(ld_date,"yyyy-mm-dd")+"'",1,ads_holidays.rowcount())=0 then li_return++ end if ld_date=relativedate(ld_date,1) loop return li_return end function public function integer of_countworkdays (datastore ads_holidays, string as_columnname, date ad_startdate, date ad_enddate);/*函数功能:获取指定日期之间的工作日天数 返回值:工作日天数 参数:ads_holidays datastroe存储指定节假日的数据存储对象 as_columnname string 数据窗口中存储节假日的列名 ad_startdate date 开始日期 ad_enddate date 结束日期 */ integer intdays,li_return date d_temp integer intsubstract if ad_enddate<ad_startdate then d_temp=ad_startdate ad_enddate=ad_startdate ad_startdate=d_temp end if ad_startdate=of_skipholidays(ads_holidays,as_columnname,ad_startdate,1) ad_enddate=of_skipholidays(ads_holidays,as_columnname,ad_enddate,-1) if ad_startdate>ad_enddate then li_return=0 else intdays=DaysAfter (ad_startdate, ad_enddate )+1 intsubstract=intsubstract+of_countholidays(ads_holidays,as_columnname,ad_startdate,ad_enddate) end if li_return=intdays - intsubstract return li_return end function public function integer of_countworkdays (date ad_startdate, date ad_enddate);/*函数功能:获取指定日期之间的工作日天数 返回值:工作日天数 参数:ad_startdate date 开始日期 ad_enddate date 结束日期 */ integer intdays,li_return date d_temp integer intsubstract if ad_enddate<ad_startdate then d_temp=ad_startdate ad_enddate=ad_startdate ad_startdate=d_temp end if ad_startdate=of_skipholidays(ad_startdate,1) ad_enddate=of_skipholidays(ad_enddate,-1) if ad_startdate>ad_enddate then li_return=0 else intdays=DaysAfter (ad_startdate, ad_enddate )+1 intsubstract=intsubstract+of_countholidays(ad_startdate,ad_enddate) end if li_return=intdays - intsubstract return li_return end function public function integer of_getage (date ad_brithday, date ad_date);/*函数作用:获取指定生日到指定日期的年纪 函数返回值:integer 指定生日到指定日期的年纪 参数:date ad_brithday 出生日期 date ad_date 指定日期*/ integer li_age date ld_temp if ad_brithday>ad_date then ld_temp=ad_brithday ad_brithday=ad_date ad_date=ld_temp end if li_age=of_yearsafter(ad_brithday,ad_date) if ad_date<date(year(ad_date),month(ad_brithday),day(ad_brithday)) then li_age=li_age - 1 end if return li_age end function public function long of_yearsafter (date ad_start, date ad_end);/*函数用途:获取指定日期之间的相差年度 返回值:long 相差年度 参数:date ad_start 开始日期 date ad_end 结束日期*/ date ld_temp int li_year, li_mult double adb_start, adb_end If IsNull(ad_start) or IsNull(ad_end) Then long ll_null SetNull (ll_null) Return ll_null End If If ad_start > ad_end Then ld_temp = ad_start ad_start = ad_end ad_end = ld_temp li_mult = -1 else li_mult = 1 End If li_year = year(ad_end) - year(ad_start) adb_start = month(ad_start) adb_start = adb_start + day(ad_start) / 100 adb_end = month(ad_end) adb_end = adb_end + day(ad_end) / 100 If adb_start > adb_end Then li_year -- End If Return li_year * li_mult end function public function long of_monthsafter (date ad_start, date ad_end);/* 描述: 两个日期之间的月份间隔 返回: 两个日期之间的月份间隔 参数:date ad_start 开始日期 date ad_end 结束日期 */ date ld_temp integer li_month integer li_mult If IsNull(ad_start) or IsNull(ad_end) Then long ll_null SetNull(ll_null) Return ll_null End If If ad_start > ad_end Then ld_temp = ad_start ad_start = ad_end ad_end = ld_temp li_mult = -1 else li_mult = 1 End If li_month = (year(ad_end) - year(ad_start) ) * 12 li_month = li_month + month(ad_end) - month(ad_start) If day(ad_start) > day(ad_end) Then li_month -- End If Return li_month * li_mult end function public function long of_weeksafter (date ad_start, date ad_end);/*函数用途:获取指定日期之间的相差星期数 返回值:long 相差星期数 参数:date ad_start 开始日期 date ad_end 结束日期*/ If IsNull(ad_start) or IsNull(ad_end) Then long ll_null SetNull(ll_null) Return ll_null End If Return Daysafter(ad_start,ad_end) /7 end function public function long of_secondsafter (datetime adtm_start, datetime adtm_end);/*函数用途:获取指定日期之间的相差分钟数 返回值:long 相差分钟数 参数:datetime adtm_start 开始时间 datetime adtm_end 结束时间*/ long ll_total_seconds, ll_day_adjust date ld_sdate, ld_edate time lt_stime, lt_etime If IsNull(adtm_start) or IsNull(adtm_end) Then long ll_null SetNull(ll_null) Return ll_null End If ld_sdate = date(adtm_start) ld_edate = date(adtm_end) lt_stime = time(adtm_start) lt_etime = time(adtm_end) If ld_sdate = ld_edate then ll_total_seconds = secondsafter( lt_stime,lt_etime) Elseif ld_sdate < ld_edate Then ll_total_seconds = SecondsAfter(lt_stime,Time('23:59:59')) ll_day_adjust = DaysAfter(ld_sdate,ld_edate) -1 If ll_day_adjust > 0 Then ll_total_seconds = ll_total_seconds + 86400 * ll_day_adjust ll_total_seconds = ll_total_seconds + SecondsAfter(Time('00:00:00'),lt_etime) +1 Else ll_total_seconds = SecondsAfter(lt_stime,Time('00:00:00')) ll_day_adjust = DaysAfter(ld_sdate,ld_edate) +1 If ll_day_adjust < 0 Then ll_total_seconds = ll_total_seconds + 86400 * ll_day_adjust ll_total_seconds = ll_total_seconds + SecondsAfter(Time('23:59:59'),lt_etime) -1 end If return ll_total_seconds end function public function long of_millisecsafter (time atm_start, time atm_end);/*函数用途:获取指定时间之间的相差秒数 返回值:long 相差相差秒数 参数:time atm_start 开始时间 time atm_end 结束时间*/ Long ll_start, ll_end Long ll_temp If IsNull(atm_start) or IsNull(atm_end) Then long ll_null SetNull(ll_null) Return ll_null End If ll_start = Long (String (atm_start,"fff")) ll_temp = Second(atm_start) * 1000 ll_start = ll_start + ll_temp ll_temp = Minute(atm_start) * 60000 ll_start = ll_start + ll_temp ll_temp = hour(atm_start) * 3600000 ll_start = ll_start + ll_temp ll_end = Long (String (atm_end,"fff")) ll_temp = Second(atm_end) * 1000 ll_end = ll_end + ll_temp ll_temp = minute(atm_end) * 60000 ll_end = ll_end + ll_temp ll_temp = hour(atm_end) * 3600000 ll_end = ll_end + ll_temp return ll_end - ll_start end function public function date of_relativemonth (date ad_source, integer al_month);/*函数功能:返回指定日期相差指定月份后的日期 返回值:date 指定日期相差指定月份后的日期 参数:date ad_source 初始日期 integer al_month 月数*/ integer li_adjust_months, li_adjust_years integer li_month, li_year, li_day integer li_temp_month If IsNull(ad_source) or IsNull(al_month) Then date ldt_null SetNull(ldt_null) Return ldt_null End If li_adjust_months = mod(al_month, 12) li_adjust_years = (al_month / 12) li_temp_month = Month(ad_source) + li_adjust_months If li_temp_month > 12 Then li_month = li_temp_month - 12 li_adjust_years ++ ElseIf li_temp_month <= 0 Then li_month = li_temp_month + 12 li_adjust_years -- Else li_month = li_temp_month End If li_year = Year(ad_source) + li_adjust_years li_day = Day(ad_source) Do While li_day > 0 li_day -- Loop Date ld_Ret ld_Ret = Date(li_year, li_month, li_day) Return ld_Ret end function public function datetime of_relativedatetime (datetime adtm_start, integer al_offset);/*函数功能:返回指定时间相差指定秒数后的时间 返回值:datetime 指定时间相差指定秒数后的时间 参数:datetime adtm_start 初始时间 integer al_month 秒数*/ datetime ldt_null date ld_sdate time lt_stime long ll_date_adjust long ll_time_adjust, ll_time_test If IsNull(adtm_start) or IsNull(al_offset) Then SetNull(ldt_null) Return ldt_null End If ld_sdate = date(adtm_start) lt_stime = time(adtm_start) ll_date_adjust = al_offset / 86400 ll_time_adjust = mod(al_offset, 86400) ld_sdate = RelativeDate(ld_sdate, ll_date_adjust) If ll_time_adjust > 0 then ll_time_test = SecondsAfter(lt_stime,time('23:59:59')) If ll_time_test < ll_time_adjust Then ld_sdate = RelativeDate(ld_sdate,1) ll_time_adjust = ll_time_adjust - ll_time_test -1 lt_stime = time('00:00:00') End If lt_stime = RelativeTime(lt_stime, ll_time_adjust) ElseIf ll_time_adjust < 0 then ll_time_test = SecondsAfter(lt_stime,time('00:00:00')) If ll_time_test > ll_time_adjust Then ld_sdate = RelativeDate(ld_sdate,-1) ll_time_adjust = ll_time_adjust - ll_time_test +1 lt_stime = time('23:59:59') End If lt_stime = RelativeTime(lt_stime, ll_time_adjust) End If return(datetime(ld_sdate,lt_stime)) end function public function integer of_getquarter (date ad_source);/*函数功能:获得指定日期所在的季度 返回值:integer 指定日期所在的季度 参数:date ad_source日期*/ IF IsNull(ad_source) THEN Long ll_null SetNull(ll_null) Return ll_null END IF Integer li_Month , li_Quarter li_Month = Month(ad_Source) li_Quarter = (li_Month -1)/3 Return li_Quarter end function public function integer of_getquarter ();/*函数功能:获得当前日期所在的季度 返回值:integer 当前日期所在的季度*/ Integer li_Month , li_Quarter li_Month = Month(today()) li_Quarter = (li_Month -1)/3 Return li_Quarter end function public function date of_getfirstdayinquarter (date ad_date);/*函数用途:获取指定日期所在的季度的第一天 返回值:date 指定日期所在的季度的第一天 参数:date ad_date 指定日期*/ date ld_return constant integer li_monthsinquarter=3 ld_return=date(year(ad_date),int((month(ad_date) - 1)/li_monthsinquarter)*li_monthsinquarter+1,1) return ld_return end function public function date of_getfirstdayinquarter ();/*函数用途:获取当前日期所在的季度的第一天 返回值:date 当前日期所在的季度的第一天*/ date ld_return constant integer li_monthsinquarter=3 ld_return=date(year(today()),int((month(today()) - 1)/li_monthsinquarter)*li_monthsinquarter+1,1) return ld_return end function public function date of_getlastdayinquarter (date ad_date);/*函数用途:获取指定日期所在的季度的最后一天 返回值:date 指定日期所在的季度的最后一天 参数:date ad_date 指定日期*/ date ld_return constant integer li_monthsinquarter=3 ld_return=date(year(ad_date),int((month(ad_date) - 1)/li_monthsinquarter)*li_monthsinquarter+(li_monthsinquarter+1),integer(28+integer(mid('3'+string(abs(sign(mod(sign(mod(abs(year(ad_date)),4))+sign(mod(abs(year(ad_date)),100))+sign(mod(abs(year(ad_date)),400)),2)) -1))+'3232332323',month(ad_date),1)))) return ld_return end function public function date of_getlastdayinquarter ();/*函数用途:获取当前日期所在的季度的最后一天 返回值:date 当前日期所在的季度的最后一天*/ date ld_return constant integer li_monthsinquarter=3 ld_return=date(year(today()),int((month(today()) - 1)/li_monthsinquarter)*li_monthsinquarter+(li_monthsinquarter+1),integer(28+integer(mid('3'+string(abs(sign(mod(sign(mod(abs(year(today())),4))+sign(mod(abs(year(today())),100))+sign(mod(abs(year(today())),400)),2)) -1))+'3232332323',month(today()),1)))) return ld_return end function public function long of_countweeksinyear (date ad_source);/*函数用途:获取指定日期所在年份的星期数 返回值:long 返回日期所在年份的星期数 参数:date ad_source 指定日期*/ date ld_first_ofyear integer li_weeknumber integer li_leftover_days If IsNull(ad_source) Then long ll_null SetNull(ll_null) Return ll_null End If ld_first_ofyear = Date(Year(ad_source), 1, 1) li_weeknumber = of_WeeksAfter (ld_first_ofyear, ad_source) + 1 li_leftover_days = Mod(DaysAfter (ld_first_ofyear, ad_source), 7) If (of_getdayinweek(ld_first_ofyear) + li_leftover_days) >= 8 then li_weeknumber ++ End If Return li_weeknumber end function public function integer of_getdayinweek (date ad_source);// 描述: 决定日期是星期几,以星期天作为一个星期的第一天 // 参数: // [value] date ad_source <描述> // 返回: (INTEGER) // 1 - If the Day is Sunday. // 2 - If the Day is Monday // 3 - If the Day is Tuesday. // 4 - If the Day is Wednesday. // 5 - If the Day is Thursday. // 6 - If the Day is Friday. // 7 - If the Day is Saturday. // If any argument's value is NULL, function returns NULL. // If IsNull(ad_source) Then long ll_null SetNull(ll_null) Return ll_null End If return DayNumber (ad_source) end function public function date of_getfirstdayinyear (date ad_date);/*函数功能:获取指定日期所在年份的第一天 返回值:date 指定日期所在年份的第一天 参数:date ad_date 日期 */ return date(year(ad_date),1,1) end function public function date of_getfirstdayinyear ();/*函数功能:获取当前日期所在年份的第一天 返回值:date 当前日期所在年份的第一天 参数:date ad_date 日期 */ return date(year(today()),1,1) end function public function date of_getfirstdayinyear (integer ai_year);/*函数功能:获取指定年份的第一天 返回值:date 指定年份的第一天 参数:date ad_date 日期 */ return date(ai_year,1,1) end function public function date of_getlastdayinyear (date ad_date);/*函数功能:获取指定日期所在年份的最后一天 返回值:date 指定日期所在年份的最后一天 参数:date ad_date 日期 */ return date(year(ad_date),12,31) end function public function date of_getlastdayinyear ();/*函数功能:获取当前日期所在年份的最后一天 返回值:date 当前日期所在年份的最后一天 参数:date ad_date 日期 */ return date(year(today()),12,31) end function public function date of_getlastdayinyear (integer ai_year);/*函数功能:获取指定日期所在年份的最后一天 返回值:date 指定日期所在年份的最后一天 参数:integer ai_year 年份 */ return date(ai_year,12,31) end function public function integer of_countyeardays (date ad_date);/*函数用途:获取指定日期所在年份的天数 函数返回值:integer 天数 参数:date ad_date 日期*/ return daysafter(of_getfirstdayinyear(ad_date),of_getlastdayinyear(ad_date)) end function public function integer of_countyeardays ();/*函数用途:获取当前日期所在年份的天数 函数返回值:integer 天数*/ return daysafter(of_getfirstdayinyear(),of_getlastdayinyear()) end function public function integer of_countyeardays (integer ai_year);/*函数用途:获取指定年份的天数 函数返回值:integer 天数 参数:integer ai_year 年份*/ return daysafter(of_getfirstdayinyear(ai_year),of_getlastdayinyear(ai_year)) end function public function string of_getconstellation (date ad_date);/*函数用途:返回指定日期所在星座 返回值:string 指定日期所在星座 参数:date ad_date 指定日期*/ return mid("摩羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手摩羯",(month(ad_date)+sign(sign(day(ad_date) -(19+integer(mid('102123444423',month(ad_date),1))))+1))*4 -3,4)+'座' end function public function string of_getgenus (integer ai_year);/*函数功能:获取指定年份的生肖 返回值:string 返回指定的年份的生肖 参数:ai_year integer 年份*/ string ls_return setnull(ls_return) if ai_year <1900 then return ls_return ls_return=mid(fill('鼠牛虎兔龙蛇马羊猴鸡狗猪',48),(mod(ai_year -1900,12)+13)*2 -1,2) return ls_return end function public function string of_convertdayoflunar (date ad_date);string WeekName[0 to 7],TianGan[0 to 9],DiZhi[0 to 11],ShuXiang[0 to 11],DayName[0 to 30],MonName[0 to 12] long MonthAdd[0 to 11],NongliData[0 to 99] long curTime, curYear, curMonth, curDay, curWeekday string GongliStr, WeekdayStr, NongliStr, NongliDayStr long i, m, n, k, isEnd, bit,thedate WeekName[0] = " * " WeekName[1] = "星期日" WeekName[2] = "星期一" WeekName[3] = "星期二" WeekName[4] = "星期三" WeekName[5] = "星期四" WeekName[6] = "星期五" WeekName[7] = "星期六" //天干名称 TianGan[0] = "甲" TianGan[1] = "乙" TianGan[2] = "丙" TianGan[3] = "丁" TianGan[4] = "戊" TianGan[5] = "己" TianGan[6] = "庚" TianGan[7] = "辛" TianGan[8] = "壬" TianGan[9] = "癸" //地支名称 DiZhi[0] = "子" DiZhi[1] = "丑" DiZhi[2] = "寅" DiZhi[3] = "卯" DiZhi[4] = "辰" DiZhi[5] = "巳" DiZhi[6] = "午" DiZhi[7] = "未" DiZhi[8] = "申" DiZhi[9] = "酉" DiZhi[10] = "戌" DiZhi[11] = "亥" //属相名称 ShuXiang[0] = "鼠" ShuXiang[1] = "牛" ShuXiang[2] = "虎" ShuXiang[3] = "兔" ShuXiang[4] = "龙" ShuXiang[5] = "蛇" ShuXiang[6] = "马" ShuXiang[7] = "羊" ShuXiang[8] = "猴" ShuXiang[9] = "鸡" ShuXiang[10] = "狗" ShuXiang[11] = "猪" //农历日期名 DayName[0] = "*" DayName[1] = "初一" DayName[2] = "初二" DayName[3] = "初三" DayName[4] = "初四" DayName[5] = "初五" DayName[6] = "初六" DayName[7] = "初七" DayName[8] = "初八" DayName[9] = "初九" DayName[10] = "初十" DayName[11] = "十一" DayName[12] = "十二" DayName[13] = "十三" DayName[14] = "十四" DayName[15] = "十五" DayName[16] = "十六" DayName[17] = "十七" DayName[18] = "十八" DayName[19] = "十九" DayName[20] = "二十" DayName[21] = "廿一" DayName[22] = "廿二" DayName[23] = "廿三" DayName[24] = "廿四" DayName[25] = "廿五" DayName[26] = "廿六" DayName[27] = "廿七" DayName[28] = "廿八" DayName[29] = "廿九" DayName[30] = "三十" //农历月份名 MonName[0] = "*" MonName[1] = "正" MonName[2] = "二" MonName[3] = "三" MonName[4] = "四" MonName[5] = "五" MonName[6] = "六" MonName[7] = "七" MonName[8] = "八" MonName[9] = "九" MonName[10] = "十" MonName[11] = "十一" MonName[12] = "腊" //公历每月前面的天数 MonthAdd[0] = 0 MonthAdd[1] = 31 MonthAdd[2] = 59 MonthAdd[3] = 90 MonthAdd[4] = 120 MonthAdd[5] = 151 MonthAdd[6] = 181 MonthAdd[7] = 212 MonthAdd[8] = 243 MonthAdd[9] = 273 MonthAdd[10] = 304 MonthAdd[11] = 334 //农历数据 NongliData[0] = 2635 NongliData[1] = 333387 NongliData[2] = 1701 NongliData[3] = 1748 NongliData[4] = 267701 NongliData[5] = 694 NongliData[6] = 2391 NongliData[7] = 133423 NongliData[8] = 1175 NongliData[9] = 396438 NongliData[10] = 3402 NongliData[11] = 3749 NongliData[12] = 331177 NongliData[13] = 1453 NongliData[14] = 694 NongliData[15] = 201326 NongliData[16] = 2350 NongliData[17] = 465197 NongliData[18] = 3221 NongliData[19] = 3402 NongliData[20] = 400202 NongliData[21] = 2901 NongliData[22] = 1386 NongliData[23] = 267611 NongliData[24] = 605 NongliData[25] = 2349 NongliData[26] = 137515 NongliData[27] = 2709 NongliData[28] = 464533 NongliData[29] = 1738 NongliData[30] = 2901 NongliData[31] = 330421 NongliData[32] = 1242 NongliData[33] = 2651 NongliData[34] = 199255 NongliData[35] = 1323 NongliData[36] = 529706 NongliData[37] = 3733 NongliData[38] = 1706 NongliData[39] = 398762 NongliData[40] = 2741 NongliData[41] = 1206 NongliData[42] = 267438 NongliData[43] = 2647 NongliData[44] = 1318 NongliData[45] = 204070 NongliData[46] = 3477 NongliData[47] = 461653 NongliData[48] = 1386 NongliData[49] = 2413 NongliData[50] = 330077 NongliData[51] = 1197 NongliData[52] = 2637 NongliData[53] = 268877 NongliData[54] = 3365 NongliData[55] = 531109 NongliData[56] = 2900 NongliData[57] = 2922 NongliData[58] = 398042 NongliData[59] = 2395 NongliData[60] = 1179 NongliData[61] = 267415 NongliData[62] = 2635 NongliData[63] = 661067 NongliData[64] = 1701 NongliData[65] = 1748 NongliData[66] = 398772 NongliData[67] = 2742 NongliData[68] = 2391 NongliData[69] = 330031 NongliData[70] = 1175 NongliData[71] = 1611 NongliData[72] = 200010 NongliData[73] = 3749 NongliData[74] = 527717 NongliData[75] = 1452 NongliData[76] = 2742 NongliData[77] = 332397 NongliData[78] = 2350 NongliData[79] = 3222 NongliData[80] = 268949 NongliData[81] = 3402 NongliData[82] = 3493 NongliData[83] = 133973 NongliData[84] = 1386 NongliData[85] = 464219 NongliData[86] = 605 NongliData[87] = 2349 NongliData[88] = 334123 NongliData[89] = 2709 NongliData[90] = 2890 NongliData[91] = 267946 NongliData[92] = 2773 NongliData[93] = 592565 NongliData[94] = 1210 NongliData[95] = 2651 NongliData[96] = 395863 NongliData[97] = 1323 NongliData[98] = 2707 NongliData[99] = 265877 curYear = Year(ad_date) curMonth = Month(ad_date) curDay = Day(ad_date) GongliStr = string(curYear)+ "年" If (curMonth < 10) Then GongliStr = GongliStr + "0" +string(curMonth) + "月" Else GongliStr = GongliStr +string(curMonth)+"月" End If If (curDay < 10) Then GongliStr = GongliStr+ "0" +string(curDay)+"日" Else GongliStr = GongliStr+string(curDay)+"日" End If //生成当前公历星期 ==> WeekdayStr curWeekday = daynumber(ad_date) WeekdayStr = weekName[curWeekday] //计算到初始时间1921年2月8日的天数:1921-2-8(正月初一) TheDate = (curYear - 1921) * 365 + Int((curYear - 1921) / 4) + curDay + MonthAdd[curMonth - 1] - 38 If (mod(CurYear,4) = 0 And curMonth > 2) Then TheDate = TheDate+1 End If //计算农历天干、地支、月、日 isEnd = 0 m = 0 Do If (NongliData[m] < 4095) Then k = 11 Else k = 12 End If n = k Do If (n < 0) Then Exit End If //获取NongliData(m)的第n个二进制位的值 bit = NongliData[m] For i = 1 To n Step 1 bit = Int(bit / 2) Next bit = mod(bit,2) If (TheDate <= 29 + bit) Then isEnd = 1 Exit End If TheDate = TheDate - 29 - bit n = n - 1 loop until 1<>1 If (isEnd = 1) Then Exit End If m = m + 1 Loop until 1<>1 curYear = 1921 + m curMonth = k - n + 1 curDay = TheDate If (k = 12) Then If (curMonth = (Int(NongliData[m] / 65536) + 1)) Then curMonth = 1 - curMonth ElseIf (curMonth > (Int(NongliData[m] / 65536) + 1)) Then curMonth = curMonth - 1 End If End If //生成农历天干、地支、属相 ==> NongliStr NongliStr = "农历" + TianGan[mod(mod(curYear - 4,60),10)] + DiZhi[mod(mod(curYear - 4, 60),12)] + "年" NongliStr = NongliStr +"(" + ShuXiang[mod(mod(curYear - 4,60),12)] + ")" //生成农历月、日 ==> NongliDayStr If (curMonth < 1) Then NongliDayStr = "闰" + MonName[-1 * curMonth] Else NongliDayStr = MonName[curMonth] End If NongliDayStr = NongliDayStr + "月" NongliDayStr = NongliDayStr+DayName[curDay] return nonglistr+nonglidaystr end function public function datetime of_relativedatetime (datetime ad_datetime, long al_number, string as_kind);//*******************************************************************************\\ //函数名:f_RelativeDataTime(datatime ad_datetime, long al_number, string al_kind) //用 途:计算datatime类型的相对日期时间 //输 入:日期时间、相对数量、单位(天、小时、分、秒) //输 出:推算后的日期时间 //*******************************************************************************\\ long ll_relativesecond,ll_second time lt_time date ld_date constant long ONEDAYSECOND = 86400 ld_date = date(ad_datetime) lt_time = time(ad_datetime) choose case as_kind case "天" return datetime(relativedate(ld_date,al_number),lt_time) case "小时" ll_relativesecond = al_number * 3600 case "分" ll_relativesecond = al_number * 60 case "秒" ll_relativesecond = al_number end choose ll_second = hour(lt_time) * 3600 + minute(lt_time) * 60 + second(lt_time) ld_date = relativedate(ld_date,integer(ll_relativesecond/ONEDAYSECOND)) ll_relativesecond -= integer(ll_relativesecond/ONEDAYSECOND) * ONEDAYSECOND if (ll_second + ll_relativesecond < 0) then return datetime(relativedate(ld_date,-1),relativetime(time("00:00:00:000"),ONEDAYSECOND + ll_second + ll_relativesecond)) end if if (ll_second + ll_relativesecond > ONEDAYSECOND) then return datetime(relativedate(ld_date,1),relativetime(time("00:00:00:000"),ll_second + ll_relativesecond - ONEDAYSECOND)) end if return datetime(ld_date,relativetime(lt_time,ll_relativesecond)) end function public function string of_gettgdz (integer ai_year);/*函数功能:获取指定年份的天干地支 返回值:string 返回指定的年份的天干地支 参数:ai_year integer 年份*/ string ls_return setnull(ls_return) if ai_year <1924 then return ls_return ls_return=mid(fill('甲乙丙丁戊己庚辛壬癸',40),(mod(ai_year -1924,10)+11)*2 -1,2)+mid(fill('子丑寅卯辰巳午未申酉戌亥',48),(mod(ai_year -1924,12)+13)*2 -1,2) return ls_return end function public function string of_gettgdz (date ad_date);/*函数功能:获取指定日期所在年份的天干地支 返回值:string 返回指定日期所在年份的天干地支 参数:ad_date date 年份*/ integer al_year string ls_return setnull(ls_return) al_year=year(ad_date) if al_year <1924 then return ls_return ls_return=mid(fill('甲乙丙丁戊己庚辛壬癸',40),(mod(al_year -1924,10)+11)*2 -1,2)+mid(fill('子丑寅卯辰巳午未申酉戌亥',48),(mod(al_year -1924,12)+13)*2 -1,2) return ls_return end function public function string of_gettgdz ();/*函数功能:获取当前日期所在年份的天干地支 返回值:string 返回当前日期所在年份的天干地支*/ integer al_year string ls_return setnull(ls_return) al_year=year(today()) if al_year <1924 then return ls_return ls_return=mid(fill('甲乙丙丁戊己庚辛壬癸',40),(mod(al_year -1924,10)+11)*2 -1,2)+mid(fill('子丑寅卯辰巳午未申酉戌亥',48),(mod(al_year -1924,12)+13)*2 -1,2) return ls_return end function public function boolean of_isleapyear ();/*函数功能:获取当前日期所在年份是否为闰年 返回值:boolean 当前日期所在年份是否为闰年,true为是闰年,false为平年*/ integer li_year li_year=year(today()) return abs(sign(mod(sign(mod(abs(li_year),4))+sign(mod(abs(li_year),100))+sign(mod(abs(li_year),400)),2)) -1)=1 end function public function string of_getgenus (date ad_date);/*函数功能:获取指定日期所在年份的生肖 返回值:string 返回指定日期所在年份的生肖 参数:ad_date date 日期*/ integer li_year string ls_return li_year=year(ad_date) setnull(ls_return) if li_year <1900 then return ls_return ls_return=mid(fill('鼠牛虎兔龙蛇马羊猴鸡狗猪',48),(mod(li_year -1900,12)+13)*2 -1,2) return ls_return end function public function string of_getgenus ();/*函数功能:获取当前日期所在年份的生肖 返回值:string 返回当前日期所在年份的生肖 */ integer li_year string ls_return li_year=year(today()) setnull(ls_return) if li_year <1900 then return ls_return ls_return=mid(fill('鼠牛虎兔龙蛇马羊猴鸡狗猪',48),(mod(li_year -1900,12)+13)*2 -1,2) return ls_return end function public function integer of_countdowinmonth ();/*函数功能:获取当前日期所在月份的星期一的天数 返回值:integer 当前日期所在月份的星期一的天数 */ return of_countdowinmonth(today(),2) end function public function integer of_getage (date ad_brithday);/*函数作用:获取指定生日到当前日期的年纪 函数返回值:integer 指定生日到当前日期的年纪 参数:date ad_brithday 出生日期*/ integer li_age date ld_date date ld_temp ld_date=today() if ad_brithday>ld_date then ld_temp=ad_brithday ad_brithday=ld_date ld_date=ld_temp end if li_age=of_yearsafter(ad_brithday,ld_date) if ld_date<date(year(ld_date),month(ad_brithday),day(ad_brithday)) then li_age=li_age - 1 end if return li_age end function public function integer of_countdowinmonth (integer ai_dow);/*函数功能:获取当前日期所在月份的指定星期几的天数 返回值:integer 指定当前所在月份的指定星期几的天数 参数: ai_dow integer 指定的星期几 1代表星期天......7代表星期六*/ date d_first integer intcount,intmonth if(ai_dow<1 or ai_dow>7) then ai_dow=daynumber(today()) end if intmonth=month(today()) d_first=date(year(today()),month(today()),1) do while daynumber(d_first)<>ai_dow d_first=relativedate(d_first,1) loop intcount=0 do while month(d_first)=intmonth intcount=intcount+1 d_first=relativedate(d_first,7) loop return intcount end function public function long of_countweeksinyear ();/*函数用途:获取当前日期所在年份的星期数 返回值:long 返回当前日期所在年份的星期数*/ date ld_first_ofyear integer li_weeknumber integer li_leftover_days ld_first_ofyear = Date(Year(today()), 1, 1) li_weeknumber = of_WeeksAfter (ld_first_ofyear, today()) + 1 li_leftover_days = Mod(DaysAfter (ld_first_ofyear, today()), 7) If (of_getdayinweek(ld_first_ofyear) + li_leftover_days) >= 8 then li_weeknumber ++ End If Return li_weeknumber end function public function boolean of_setsystemtime (datetime adt_datetime);stc_systemtime lstc_systemtime date ld_date time lt_time ld_date=date(adt_datetime) lt_time=time(adt_datetime) lstc_systemtime.wyear=year(ld_date) lstc_systemtime.wmonth=month(ld_date) lstc_systemtime.wday=day(ld_date) lstc_systemtime.wdayofweek=daynumber(ld_date) lstc_systemtime.whour=hour(lt_time) lstc_systemtime.wminute=minute(lt_time) lstc_systemtime.wsecond=minute(lt_time) lstc_systemtime.wmilliseconds=0 return setsystemtime(lstc_systemtime)<>0 end function on nvo_datetime.create call super::create TriggerEvent( this, "constructor" ) end on on nvo_datetime.destroy TriggerEvent( this, "destructor" ) call super::destroy end on event constructor;//**********************************************************// //nvo_datetime 日期时间操作类 ,自创建不可视用户对象 // //author:tiantianpb // //write date:2003-11-16 // //used:对各种常用的日期时间操作进行了相关的封装 // //********************************************************* // end event

本文地址:http://com.8s8s.com/it/it20462.htm