$pbexportheader$nvo_datetime.sru$pbexportcomments$日期时间操作类forwardglobal type nvo_datetime from nonvisualobjectend typetype stc_systemtime from structure within nvo_datetimeend typeend forwardtype stc_systemtime from structure integer wyear integer wmonth integer wdayofweek integer wday integer whour integer wminute integer wsecond integer wmillisecondsend typeglobal type nvo_datetime from nonvisualobject autoinstantiateend typetype prototypesfunction long setsystemtime(stc_systemtime lpsystemtime) library “kernel32.dll” end prototypesforward prototypespublic 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 prototypespublic 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 functionpublic 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 functionpublic function date of_getlastdayinmonth (integer ai_year, integer ai_month);/*函数功能:获取指定年份,月份的最后一天 返回值:date 指定年份,月份的最后一天 参数:integer ai_year 年份 integer ai_month 月份*/date ld_dateld_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 functionpublic function date of_getfirstdayinmonth (date ad_date);/*函数功能:获取指定日期所在月份的第一天 返回值:date 指定日期所在月份的第一天 参数:date ad_date 日期 */return date(year(ad_date),month(ad_date),1)end functionpublic 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 functionpublic function boolean of_isleapyear (date ad_date);/*函数功能:获取指定日期所在年份是否为闰年 返回值:boolean 指定日期所在年份是否为闰年,true为是闰年,false为平年 参数:ad_date date 日期*/integer li_yearli_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)=1end functionpublic 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)=1end functionpublic function boolean of_lsweekend (date ad_date);/*函数功能:获取指定日期是否为周末 返回值:date 指定日期是否为周末 参数:ad_date date 日期*/string ls_weekls_week=dayname(ad_date)choose case dayname(ad_date) case “saturday”,”sunday” return true case else return falseend chooseend functionpublic function date of_skipholidays (date ad_date, integer ai_increment);/*函数功能:获取指定日期跳过周末的下一个日期 返回值:date 返回指定的指定日期跳过周末的下一个日期 参数:ad_date date 日期 ai_increment integer 指定的跳过天数 */date ld_dateld_date=ad_datedo while of_lsweekend(ld_date)=true ld_date=relativedate ( ld_date, ai_increment ) loop return ld_dateend functionpublic 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 functionpublic 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 functionpublic function date of_getpreviousworkday (date ad_date);/*函数功能:获取指定日期跳过周末的上一个工作日 返回值:date 返回指定的指定日期跳过周末的上一个工作日 参数: ad_date date 日期 */return of_skipholidays(relativedate (ad_date,-1),-1)end functionpublic function date of_getnextworkday (date ad_date);/*函数功能:获取指定日期跳过周末的下一个工作日 返回值:date 返回指定的指定日期跳过周末的下一个工作日 参数: ad_date date 日期 */return of_skipholidays(relativedate (ad_date,1),1)end functionpublic 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_dateld_date=ad_datedo 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_dateend functionpublic 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_dateld_date=ad_datedo 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_dateend functionpublic 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 functionpublic 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_tempd_temp=date(year(ad_date),month(ad_date),1)return of_skipholidays(adw_holidays,as_columnname,d_temp,1)end functionpublic 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_tempd_temp=date(year(ad_date),month(ad_date),1)return of_skipholidays(ads_holidays,as_columnname,d_temp,1)end functionpublic 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 functionpublic function date of_getfirstworkday (date ad_date);/*函数功能:获取指定日期所在月的第一个工作日 返回值:date 返回指定日期所在月的第一个工作日 参数: ad_date date 日期 */date d_tempd_temp=date(year(ad_date),month(ad_date),1)return of_skipholidays(d_temp,1)end functionpublic 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_tempd_temp=of_getlastdayinmonth(ad_date)return of_skipholidays(ads_holidays,as_columnname,d_temp,-1)end functionpublic 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_tempd_temp=of_getlastdayinmonth(ad_date)return of_skipholidays(adw_holidays,as_columnname,d_temp,-1)end functionpublic function date of_getlastworkday (date ad_date);/*函数功能:获取指定日期所在月的最后一个工作日 返回值:date 返回指定日期所在月的最后一个工作日 参数: ad_date date 日期 */date d_tempd_temp=of_getlastdayinmonth(ad_date)return of_skipholidays(d_temp,-1)end functionpublic 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 functionpublic function integer of_countdowinmonth (date ad_date, integer ai_dow);/*函数功能:获取指定日期所在月份的指定星期几的天数 返回值:integer 指定日期所在月份的指定星期几的天数 参数:ad_date date 日期 ai_dow integer 指定的星期几 1代表星期天……7代表星期六*/date d_firstinteger intcount,intmonthif(ai_dow<1 or ai_dow>7) then ai_dow=daynumber(ad_date)end ifintmonth=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)loopintcount=0do while month(d_first)=intmonth intcount=intcount+1 d_first=relativedate(d_first,7)loopreturn intcountend functionpublic function integer of_countdowinmonth (date ad_date);/*函数功能:获取指定日期所在月份的星期一的天数 返回值:integer 指定日期所在月份的星期一的天数 参数:ad_date date 日期*/ return of_countdowinmonth(ad_date,2)end functionpublic 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_returndate d_tempinteger intsubstractif ad_enddate<ad_startdate then d_temp=ad_startdate ad_enddate=ad_startdate ad_startdate=d_tempend ifad_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=0else intdays=daysafter (ad_startdate, ad_enddate )+1 intsubstract=intsubstract+of_countholidays(adw_holidays,as_columnname,ad_startdate,ad_enddate)end ifli_return=intdays – intsubstractreturn li_returnend functionpublic function date of_getfirstdayinweek (date ad_date);/*函数功能:获取指定日期所在周的第一天 返回值:date 返回指定日期所在周的第一天 参数:ad_date date 日期 */date ld_returnld_return=relativedate (ad_date, 1 – daynumber(ad_date))return ld_returnend functionpublic function date of_getlastdayinweek (date ad_date);/*函数功能:获取指定日期所在周的最后一天 返回值:date 返回指定日期所在周的最后一天 参数:ad_date date 日期 */date ld_returnld_return=relativedate (ad_date, 7 – daynumber(ad_date))return ld_returnend functionpublic function date of_getfirstdayinmonth ();/*函数功能:获取当前日期所在月份的第一天 返回值:date 当前日期所在月份的第一天 参数:date ad_date 日期 */return date(year(today()),month(today()),1)end functionpublic 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 functionpublic function date of_getfirstworkday ();/*函数功能:获取当前日期所在月的第一个工作日 返回值:date 返回当前日期所在月的第一个工作日 */date d_tempd_temp=date(year(today()),month(today()),1)return of_skipholidays(d_temp,1)end functionpublic function date of_getlastworkday ();/*函数功能:获取当前日期所在月的最后一个工作日 返回值:date 返回当前日期所在月的最后一个工作日 */ date d_tempd_temp=of_getlastdayinmonth(today())return of_skipholidays(d_temp,-1)end functionpublic function date of_getfirstdayinweek ();/*函数功能:获取当前日期所在周的第一天 返回值:date 返回当前日期所在周的第一天 参数:ad_date date 日期 */date ld_returnld_return=relativedate (today(), 1 – daynumber(today()))return ld_returnend functionpublic function date of_getlastdayinweek ();/*函数功能:获取指定日期所在周的最后一天 返回值:date 返回指定日期所在周的最后一天*/date ld_returnld_return=relativedate (today(), 7 – daynumber(today()))return ld_returnend functionpublic function date of_getnextworkday ();/*函数功能:获取当前日期跳过周末的下一个工作日 返回值:date 返回当前的指定日期跳过周末的下一个工作日 */return of_skipholidays(relativedate (today(),1),1)end functionpublic function date of_getpreviousworkday ();/*函数功能:获取当前日期跳过周末的上一个工作日 返回值:date 返回当前日期跳过周末的上一个工作日 */return of_skipholidays(relativedate (today(),-1),-1)end functionpublic 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_returndate ld_dateld_date=ad_startdatedo 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_returnend functionpublic function integer of_countholidays (date ad_startdate, date ad_enddate);/*函数功能:获取指定日期之间的节假日天数 返回值:节假日天数 参数:ad_startdate date 开始日期 ad_enddate date 结束日期 */ integer li_returndate ld_dateld_date=ad_startdatedo 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_returnend functionpublic 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_returndate ld_dateld_date=ad_startdatedo 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_returnend functionpublic 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_returndate d_tempinteger intsubstractif ad_enddate<ad_startdate then d_temp=ad_startdate ad_enddate=ad_startdate ad_startdate=d_tempend ifad_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=0else intdays=daysafter (ad_startdate, ad_enddate )+1 intsubstract=intsubstract+of_countholidays(ads_holidays,as_columnname,ad_startdate,ad_enddate)end ifli_return=intdays – intsubstractreturn li_returnend functionpublic function integer of_countworkdays (date ad_startdate, date ad_enddate);/*函数功能:获取指定日期之间的工作日天数 返回值:工作日天数 参数:ad_startdate date 开始日期 ad_enddate date 结束日期 */ integer intdays,li_returndate d_tempinteger intsubstractif ad_enddate<ad_startdate then d_temp=ad_startdate ad_enddate=ad_startdate ad_startdate=d_tempend ifad_startdate=of_skipholidays(ad_startdate,1)ad_enddate=of_skipholidays(ad_enddate,-1)if ad_startdate>ad_enddate then li_return=0else intdays=daysafter (ad_startdate, ad_enddate )+1 intsubstract=intsubstract+of_countholidays(ad_startdate,ad_enddate)end ifli_return=intdays – intsubstractreturn li_returnend functionpublic function integer of_getage (date ad_brithday, date ad_date);/*函数作用:获取指定生日到指定日期的年纪 函数返回值:integer 指定生日到指定日期的年纪 参数:date ad_brithday 出生日期 date ad_date 指定日期*/integer li_agedate ld_tempif ad_brithday>ad_date then ld_temp=ad_brithday ad_brithday=ad_date ad_date=ld_tempend ifli_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 – 1end ifreturn li_ageend functionpublic function long of_yearsafter (date ad_start, date ad_end);/*函数用途:获取指定日期之间的相差年度 返回值:long 相差年度 参数:date ad_start 开始日期 date ad_end 结束日期*/ date ld_tempint li_year, li_multdouble adb_start, adb_endif isnull(ad_start) or isnull(ad_end) then long ll_null setnull (ll_null) return ll_nullend ifif ad_start > ad_end then ld_temp = ad_start ad_start = ad_end ad_end = ld_temp li_mult = -1else li_mult = 1end ifli_year = year(ad_end) – year(ad_start)adb_start = month(ad_start)adb_start = adb_start + day(ad_start) / 100adb_end = month(ad_end)adb_end = adb_end + day(ad_end) / 100if adb_start > adb_end then li_year –end ifreturn li_year * li_multend functionpublic function long of_monthsafter (date ad_start, date ad_end);/* 描述: 两个日期之间的月份间隔返回: 两个日期之间的月份间隔参数:date ad_start 开始日期 date ad_end 结束日期 */ date ld_tempinteger li_monthinteger li_multif isnull(ad_start) or isnull(ad_end) then long ll_null setnull(ll_null) return ll_nullend ifif ad_start > ad_end then ld_temp = ad_start ad_start = ad_end ad_end = ld_temp li_mult = -1else li_mult = 1end ifli_month = (year(ad_end) – year(ad_start) ) * 12li_month = li_month + month(ad_end) – month(ad_start)if day(ad_start) > day(ad_end) then li_month –end ifreturn li_month * li_multend functionpublic 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_nullend ifreturn daysafter(ad_start,ad_end) /7end functionpublic function long of_secondsafter (datetime adtm_start, datetime adtm_end);/*函数用途:获取指定日期之间的相差分钟数 返回值:long 相差分钟数 参数:datetime adtm_start 开始时间 datetime adtm_end 结束时间*/ long ll_total_seconds, ll_day_adjustdate ld_sdate, ld_edatetime lt_stime, lt_etimeif isnull(adtm_start) or isnull(adtm_end) then long ll_null setnull(ll_null) return ll_nullend ifld_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) +1else 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) -1end ifreturn ll_total_secondsend functionpublic function long of_millisecsafter (time atm_start, time atm_end);/*函数用途:获取指定时间之间的相差秒数 返回值:long 相差相差秒数 参数:time atm_start 开始时间 time atm_end 结束时间*/ long ll_start, ll_endlong ll_tempif isnull(atm_start) or isnull(atm_end) then long ll_null setnull(ll_null) return ll_nullend ifll_start = long (string (atm_start,”fff”))ll_temp = second(atm_start) * 1000ll_start = ll_start + ll_templl_temp = minute(atm_start) * 60000ll_start = ll_start + ll_templl_temp = hour(atm_start) * 3600000ll_start = ll_start + ll_templl_end = long (string (atm_end,”fff”))ll_temp = second(atm_end) * 1000ll_end = ll_end + ll_templl_temp = minute(atm_end) * 60000ll_end = ll_end + ll_templl_temp = hour(atm_end) * 3600000ll_end = ll_end + ll_tempreturn ll_end – ll_startend functionpublic function date of_relativemonth (date ad_source, integer al_month);/*函数功能:返回指定日期相差指定月份后的日期返回值:date 指定日期相差指定月份后的日期参数:date ad_source 初始日期 integer al_month 月数*/integer li_adjust_months, li_adjust_yearsinteger li_month, li_year, li_dayinteger li_temp_monthif isnull(ad_source) or isnull(al_month) then date ldt_null setnull(ldt_null) return ldt_nullend ifli_adjust_months = mod(al_month, 12)li_adjust_years = (al_month / 12)li_temp_month = month(ad_source) + li_adjust_monthsif 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_monthend ifli_year = year(ad_source) + li_adjust_yearsli_day = day(ad_source)do while li_day > 0 li_day –loopdate ld_ret ld_ret = date(li_year, li_month, li_day) return ld_retend functionpublic function datetime of_relativedatetime (datetime adtm_start, integer al_offset);/*函数功能:返回指定时间相差指定秒数后的时间返回值:datetime 指定时间相差指定秒数后的时间参数:datetime adtm_start 初始时间 integer al_month 秒数*/datetime ldt_nulldate ld_sdatetime lt_stimelong ll_date_adjustlong ll_time_adjust, ll_time_testif isnull(adtm_start) or isnull(al_offset) then setnull(ldt_null) return ldt_nullend ifld_sdate = date(adtm_start)lt_stime = time(adtm_start)ll_date_adjust = al_offset / 86400ll_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 ifreturn(datetime(ld_sdate,lt_stime))end functionpublic function integer of_getquarter (date ad_source);/*函数功能:获得指定日期所在的季度返回值:integer 指定日期所在的季度参数:date ad_source日期*/if isnull(ad_source) then long ll_null setnull(ll_null) return ll_nullend ifinteger li_month , li_quarterli_month = month(ad_source)li_quarter = (li_month -1)/3return li_quarterend functionpublic function integer of_getquarter ();/*函数功能:获得当前日期所在的季度返回值:integer 当前日期所在的季度*/integer li_month , li_quarterli_month = month(today())li_quarter = (li_month -1)/3return li_quarterend functionpublic function date of_getfirstdayinquarter (date ad_date);/*函数用途:获取指定日期所在的季度的第一天返回值:date 指定日期所在的季度的第一天参数:date ad_date 指定日期*/date ld_returnconstant integer li_monthsinquarter=3ld_return=date(year(ad_date),int((month(ad_date) – 1)/li_monthsinquarter)*li_monthsinquarter+1,1)return ld_returnend functionpublic function date of_getfirstdayinquarter ();/*函数用途:获取当前日期所在的季度的第一天返回值:date 当前日期所在的季度的第一天*/date ld_returnconstant integer li_monthsinquarter=3ld_return=date(year(today()),int((month(today()) – 1)/li_monthsinquarter)*li_monthsinquarter+1,1)return ld_returnend functionpublic function date of_getlastdayinquarter (date ad_date);/*函数用途:获取指定日期所在的季度的最后一天返回值:date 指定日期所在的季度的最后一天参数:date ad_date 指定日期*/date ld_returnconstant integer li_monthsinquarter=3ld_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_returnend functionpublic function date of_getlastdayinquarter ();/*函数用途:获取当前日期所在的季度的最后一天返回值:date 当前日期所在的季度的最后一天*/date ld_returnconstant integer li_monthsinquarter=3ld_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_returnend functionpublic function long of_countweeksinyear (date ad_source);/*函数用途:获取指定日期所在年份的星期数返回值:long 返回日期所在年份的星期数参数:date ad_source 指定日期*/date ld_first_ofyearinteger li_weeknumberinteger li_leftover_daysif isnull(ad_source) then long ll_null setnull(ll_null) return ll_nullend ifld_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 ifreturn li_weeknumberend functionpublic 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 arguments value is null, function returns null.//if isnull(ad_source) then long ll_null setnull(ll_null) return ll_nullend ifreturn daynumber (ad_source)end functionpublic function date of_getfirstdayinyear (date ad_date);/*函数功能:获取指定日期所在年份的第一天 返回值:date 指定日期所在年份的第一天 参数:date ad_date 日期 */return date(year(ad_date),1,1)end functionpublic function date of_getfirstdayinyear ();/*函数功能:获取当前日期所在年份的第一天 返回值:date 当前日期所在年份的第一天 参数:date ad_date 日期 */return date(year(today()),1,1)end functionpublic function date of_getfirstdayinyear (integer ai_year);/*函数功能:获取指定年份的第一天 返回值:date 指定年份的第一天 参数:date ad_date 日期 */return date(ai_year,1,1)end functionpublic function date of_getlastdayinyear (date ad_date);/*函数功能:获取指定日期所在年份的最后一天 返回值:date 指定日期所在年份的最后一天 参数:date ad_date 日期 */return date(year(ad_date),12,31)end functionpublic function date of_getlastdayinyear ();/*函数功能:获取当前日期所在年份的最后一天 返回值:date 当前日期所在年份的最后一天 参数:date ad_date 日期 */return date(year(today()),12,31)end functionpublic function date of_getlastdayinyear (integer ai_year);/*函数功能:获取指定日期所在年份的最后一天 返回值:date 指定日期所在年份的最后一天 参数:integer ai_year 年份 */return date(ai_year,12,31)end functionpublic function integer of_countyeardays (date ad_date);/*函数用途:获取指定日期所在年份的天数函数返回值:integer 天数参数:date ad_date 日期*/return daysafter(of_getfirstdayinyear(ad_date),of_getlastdayinyear(ad_date))end functionpublic function integer of_countyeardays ();/*函数用途:获取当前日期所在年份的天数函数返回值:integer 天数*/return daysafter(of_getfirstdayinyear(),of_getlastdayinyear())end functionpublic function integer of_countyeardays (integer ai_year);/*函数用途:获取指定年份的天数函数返回值:integer 天数参数:integer ai_year 年份*/return daysafter(of_getfirstdayinyear(ai_year),of_getlastdayinyear(ai_year))end functionpublic 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 functionpublic function string of_getgenus (integer ai_year);/*函数功能:获取指定年份的生肖 返回值:string 返回指定的年份的生肖 参数:ai_year integer 年份*/string ls_returnsetnull(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_returnend functionpublic 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, curweekdaystring gonglistr, weekdaystr, nonglistr, nonglidaystrlong i, m, n, k, isend, bit,thedateweekname[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] = 0monthadd[1] = 31monthadd[2] = 59monthadd[3] = 90monthadd[4] = 120monthadd[5] = 151monthadd[6] = 181monthadd[7] = 212monthadd[8] = 243monthadd[9] = 273monthadd[10] = 304monthadd[11] = 334//农历数据nonglidata[0] = 2635nonglidata[1] = 333387nonglidata[2] = 1701nonglidata[3] = 1748nonglidata[4] = 267701nonglidata[5] = 694nonglidata[6] = 2391nonglidata[7] = 133423nonglidata[8] = 1175nonglidata[9] = 396438nonglidata[10] = 3402nonglidata[11] = 3749nonglidata[12] = 331177nonglidata[13] = 1453nonglidata[14] = 694nonglidata[15] = 201326nonglidata[16] = 2350nonglidata[17] = 465197nonglidata[18] = 3221nonglidata[19] = 3402nonglidata[20] = 400202nonglidata[21] = 2901nonglidata[22] = 1386nonglidata[23] = 267611nonglidata[24] = 605nonglidata[25] = 2349nonglidata[26] = 137515nonglidata[27] = 2709nonglidata[28] = 464533nonglidata[29] = 1738nonglidata[30] = 2901nonglidata[31] = 330421nonglidata[32] = 1242nonglidata[33] = 2651nonglidata[34] = 199255nonglidata[35] = 1323nonglidata[36] = 529706nonglidata[37] = 3733nonglidata[38] = 1706nonglidata[39] = 398762nonglidata[40] = 2741nonglidata[41] = 1206nonglidata[42] = 267438nonglidata[43] = 2647nonglidata[44] = 1318nonglidata[45] = 204070nonglidata[46] = 3477nonglidata[47] = 461653nonglidata[48] = 1386nonglidata[49] = 2413nonglidata[50] = 330077nonglidata[51] = 1197nonglidata[52] = 2637nonglidata[53] = 268877nonglidata[54] = 3365nonglidata[55] = 531109nonglidata[56] = 2900nonglidata[57] = 2922nonglidata[58] = 398042nonglidata[59] = 2395nonglidata[60] = 1179nonglidata[61] = 267415nonglidata[62] = 2635nonglidata[63] = 661067nonglidata[64] = 1701nonglidata[65] = 1748nonglidata[66] = 398772nonglidata[67] = 2742nonglidata[68] = 2391nonglidata[69] = 330031nonglidata[70] = 1175nonglidata[71] = 1611nonglidata[72] = 200010nonglidata[73] = 3749nonglidata[74] = 527717nonglidata[75] = 1452nonglidata[76] = 2742nonglidata[77] = 332397nonglidata[78] = 2350nonglidata[79] = 3222nonglidata[80] = 268949nonglidata[81] = 3402nonglidata[82] = 3493nonglidata[83] = 133973nonglidata[84] = 1386nonglidata[85] = 464219nonglidata[86] = 605nonglidata[87] = 2349nonglidata[88] = 334123nonglidata[89] = 2709nonglidata[90] = 2890nonglidata[91] = 267946nonglidata[92] = 2773nonglidata[93] = 592565nonglidata[94] = 1210nonglidata[95] = 2651nonglidata[96] = 395863nonglidata[97] = 1323nonglidata[98] = 2707nonglidata[99] = 265877curyear = 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 ifif (curday < 10) then gonglistr = gonglistr+ “0” +string(curday)+”日”else gonglistr = gonglistr+string(curday)+”日”end if//生成当前公历星期 ==> weekdaystrcurweekday = daynumber(ad_date)weekdaystr = weekname[curweekday]//计算到初始时间1921年2月8日的天数:1921-2-8(正月初一)thedate = (curyear – 1921) * 365 + int((curyear – 1921) / 4) + curday + monthadd[curmonth – 1] – 38if (mod(curyear,4) = 0 and curmonth > 2) then thedate = thedate+1end if//计算农历天干、地支、月、日isend = 0m = 0do 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 – 1loop until 1<>1 if (isend = 1) then exit end if m = m + 1loop until 1<>1curyear = 1921 + mcurmonth = k – n + 1curday = thedateif (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 ifend if//生成农历天干、地支、属相 ==> nonglistrnonglistr = “农历” + tiangan[mod(mod(curyear – 4,60),10)] + dizhi[mod(mod(curyear – 4, 60),12)] + “年”nonglistr = nonglistr +”(” + shuxiang[mod(mod(curyear – 4,60),12)] + “)”//生成农历月、日 ==> nonglidaystrif (curmonth < 1) then nonglidaystr = “闰” + monname[-1 * curmonth]else nonglidaystr = monname[curmonth]end ifnonglidaystr = nonglidaystr + “月”nonglidaystr = nonglidaystr+dayname[curday]return nonglistr+nonglidaystrend functionpublic 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_secondtime lt_timedate ld_dateconstant 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_numberend choosell_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) * onedaysecondif (ll_second + ll_relativesecond < 0) then return datetime(relativedate(ld_date,-1),relativetime(time(“00:00:00:000”),onedaysecond + ll_second + ll_relativesecond))end ifif (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 functionpublic 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_returnend functionpublic 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_returnend functionpublic 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_returnend functionpublic function boolean of_isleapyear ();/*函数功能:获取当前日期所在年份是否为闰年 返回值:boolean 当前日期所在年份是否为闰年,true为是闰年,false为平年*/integer li_yearli_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)=1end functionpublic function string of_getgenus (date ad_date);/*函数功能:获取指定日期所在年份的生肖 返回值:string 返回指定日期所在年份的生肖 参数:ad_date date 日期*/integer li_yearstring ls_returnli_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_returnend functionpublic function string of_getgenus ();/*函数功能:获取当前日期所在年份的生肖 返回值:string 返回当前日期所在年份的生肖 */integer li_yearstring ls_returnli_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_returnend functionpublic function integer of_countdowinmonth ();/*函数功能:获取当前日期所在月份的星期一的天数 返回值:integer 当前日期所在月份的星期一的天数 */ return of_countdowinmonth(today(),2)end functionpublic function integer of_getage (date ad_brithday);/*函数作用:获取指定生日到当前日期的年纪 函数返回值:integer 指定生日到当前日期的年纪 参数:date ad_brithday 出生日期*/integer li_agedate ld_datedate ld_templd_date=today()if ad_brithday>ld_date then ld_temp=ad_brithday ad_brithday=ld_date ld_date=ld_tempend ifli_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 – 1end ifreturn li_ageend functionpublic function integer of_countdowinmonth (integer ai_dow);/*函数功能:获取当前日期所在月份的指定星期几的天数 返回值:integer 指定当前所在月份的指定星期几的天数 参数: ai_dow integer 指定的星期几 1代表星期天……7代表星期六*/date d_firstinteger intcount,intmonthif(ai_dow<1 or ai_dow>7) then ai_dow=daynumber(today())end ifintmonth=month(today())d_first=date(year(today()),month(today()),1)do while daynumber(d_first)<>ai_dow d_first=relativedate(d_first,1)loopintcount=0do while month(d_first)=intmonth intcount=intcount+1 d_first=relativedate(d_first,7)loopreturn intcountend functionpublic function long of_countweeksinyear ();/*函数用途:获取当前日期所在年份的星期数返回值:long 返回当前日期所在年份的星期数*/date ld_first_ofyearinteger li_weeknumberinteger li_leftover_daysld_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 ifreturn li_weeknumberend functionpublic function boolean of_setsystemtime (datetime adt_datetime);stc_systemtime lstc_systemtimedate ld_datetime lt_timeld_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=0return setsystemtime(lstc_systemtime)<>0end functionon nvo_datetime.createcall super::createtriggerevent( this, “constructor” )end onon nvo_datetime.destroytriggerevent( this, “destructor” )call super::destroyend onevent constructor;//**********************************************************////nvo_datetime 日期时间操作类 ,自创建不可视用户对象 ////author:tiantianpb ////write date:2003-11-16 ////used:对各种常用的日期时间操作进行了相关的封装 ////********************************************************* //end event
一个自己封装的日期时间操作的用户对象-数据库专栏,SQL Server
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 一个自己封装的日期时间操作的用户对象-数据库专栏,SQL Server
相关推荐
-      使用用VB处理MYSQL数据库中二进制数据问题-.NET教程,VB.Net语言
-      DataGrid中的按钮反选事件与NamingContainer(命名容器)-downmoon-ASP教程,数据库相关
-      根据数据表中数据,生成Powerpoint幻灯片-ASP教程,数据库相关
-      关于DataGridView中如何接收处于编辑状态下的当前信息-ASP教程,数据库相关
-      ActiveMQ4.1+Spring2.0的POJO JMS方案(上)-.NET教程,数据库应用
-      ASP.NET 2.0中直接将Access数据库导入到Excel文件中-.NET教程,Asp.Net开发
-      DataGrid的多行提交-.NET教程,数据库应用
-      一个简单的asp数据库操作类-ASP教程,数据库相关