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

对象|封装

$PBExportHeader$nvo_datetime.sru$PBExportComments$日期时间操作类forwardglobal type nvo_datetime from nonvisualobjectend typetype stc_systemtime from structure within nvo_datetimeend typeend forwardtype stc_systemtime from structureintegerwyearintegerwmonthintegerwdayofweekintegerwdayintegerwhourintegerwminuteintegerwsecondintegerwmillisecondsend 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 truecase elsereturn 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)=trueld_date=RelativeDate ( ld_date, ai_increment )loopreturn 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())<>0ld_date=RelativeDate ( ld_date, ai_increment )loopreturn 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())<>0ld_date=RelativeDate ( ld_date, ai_increment )loopreturn 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_dowd_first=relativedate(d_first,1)loopintcount=0do while month(d_first)=intmonthintcount=intcount+1d_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 thend_temp=ad_startdatead_enddate=ad_startdatead_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 thenli_return=0elseintdays=DaysAfter (ad_startdate, ad_enddate )+1intsubstract=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_enddateif 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 thenli_return++end ifld_date=relativedate(ld_date,1)loopreturn 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_enddateif of_lsweekend(ld_date)=true thenli_return++end ifld_date=relativedate(ld_date,1)loopreturn 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_enddateif 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 thenli_return++end ifld_date=relativedate(ld_date,1)loopreturn 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 thend_temp=ad_startdatead_enddate=ad_startdatead_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 thenli_return=0elseintdays=DaysAfter (ad_startdate, ad_enddate )+1intsubstract=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 thend_temp=ad_startdatead_enddate=ad_startdatead_startdate=d_tempend ifad_startdate=of_skipholidays(ad_startdate,1)ad_enddate=of_skipholidays(ad_enddate,-1)if ad_startdate>ad_enddate thenli_return=0elseintdays=DaysAfter (ad_startdate, ad_enddate )+1intsubstract=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 thenld_temp=ad_brithdayad_brithday=ad_datead_date=ld_tempend ifli_age=of_yearsafter(ad_brithday,ad_date)if ad_date<date(year(ad_date),month(ad_brithday),day(ad_brithday)) thenli_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) Thenlong ll_nullSetNull (ll_null)Return ll_nullEnd IfIf ad_start > ad_end Thenld_temp = ad_startad_start = ad_endad_end = ld_templi_mult = -1elseli_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 Thenli_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_monthintegerli_multIf IsNull(ad_start) or IsNull(ad_end) Thenlong ll_nullSetNull(ll_null)Return ll_nullEnd IfIf ad_start > ad_end Thenld_temp = ad_startad_start = ad_endad_end = ld_templi_mult = -1elseli_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) Thenlong ll_nullSetNull(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) Thenlong ll_nullSetNull(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 Thenll_total_seconds = SecondsAfter(lt_stime,Time('23:59:59'))ll_day_adjust = DaysAfter(ld_sdate,ld_edate) -1If ll_day_adjust > 0 Then ll_total_seconds = ll_total_seconds + 86400 * ll_day_adjustll_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) +1If ll_day_adjust < 0 Then ll_total_seconds = ll_total_seconds + 86400 * ll_day_adjustll_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) Thenlong ll_nullSetNull(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) Thendate ldt_nullSetNull(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 Thenli_month = li_temp_month - 12li_adjust_years ++ElseIf li_temp_month <= 0 Thenli_month = li_temp_month + 12li_adjust_years --Elseli_month = li_temp_monthEnd Ifli_year = Year(ad_source) + li_adjust_yearsli_day = Day(ad_source)Do While li_day > 0li_day --LoopDateld_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) ThenSetNull(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 thenll_time_test = SecondsAfter(lt_stime,time('23:59:59'))If ll_time_test < ll_time_adjust Thenld_sdate = RelativeDate(ld_sdate,1)ll_time_adjust = ll_time_adjust - ll_time_test -1lt_stime = time('00:00:00')End Iflt_stime = RelativeTime(lt_stime, ll_time_adjust)ElseIf ll_time_adjust < 0 thenll_time_test = SecondsAfter(lt_stime,time('00:00:00'))If ll_time_test > ll_time_adjust Thenld_sdate = RelativeDate(ld_sdate,-1)ll_time_adjust = ll_time_adjust - ll_time_test +1lt_stime = time('23:59:59')End Iflt_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) THENLong ll_nullSetNull(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 指定日期*/dateld_first_ofyearintegerli_weeknumberintegerli_leftover_daysIf IsNull(ad_source) Thenlong ll_nullSetNull(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 thenli_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 argument's value is NULL, function returns NULL.//If IsNull(ad_source) Thenlong ll_nullSetNull(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_returnls_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_kindcase "天"return datetime(relativedate(ld_date,al_number),lt_time)case "小时"ll_relativesecond = al_number * 3600case "分"ll_relativesecond = al_number * 60case "秒"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) thenreturn datetime(relativedate(ld_date,-1),relativetime(time("00:00:00:000"),ONEDAYSECOND + ll_second + ll_relativesecond))end ifif (ll_second + ll_relativesecond > ONEDAYSECOND) thenreturn datetime(relativedate(ld_date,1),relativetime(time("00:00:00:000"),ll_second + ll_relativesecond - ONEDAYSECOND))end ifreturn 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_returnls_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_returnls_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 thenld_temp=ad_brithdayad_brithday=ld_dateld_date=ld_tempend ifli_age=of_yearsafter(ad_brithday,ld_date)if ld_date<date(year(ld_date),month(ad_brithday),day(ad_brithday)) thenli_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_dowd_first=relativedate(d_first,1)loopintcount=0do while month(d_first)=intmonthintcount=intcount+1d_first=relativedate(d_first,7)loopreturn intcountend functionpublic function long of_countweeksinyear ();/*函数用途:获取当前日期所在年份的星期数返回值:long 返回当前日期所在年份的星期数*/dateld_first_ofyearintegerli_weeknumberintegerli_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 thenli_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

时间: 2024-10-26 10:24:02

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

Java日期时间操作的方法_java

本文实例为大家分享了java日期时间基本操作方法,供大家参考,具体内容如下 1. 获得Calendar实例:Calendar c = Calendar.getInstance(); 2. 定义日期/时间的格式:SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 3. 把日期/时间转换成固定格式,使用SimpleDateFormat的format()方法:String datetime = sdf.form

Java日期时间正则表达式 Java日期时间操作的方法

1. 获得Calendar实例:Calendar c = Calendar.getInstance(); 2. 定义日期/时间的格式:SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 3. 把日期/时间转换成固定格式,使用SimpleDateFormat的format()方法: String datetime = sdf.format(c.getTime()); 4. 把字符串转换成日期/时间,使用Si

FLEX 日期时间操作_Flex

首先是它只有一个日期,而没有时间,所以这里也就是到年月日就到底了. 比如: 复制代码 代码如下: <mx:DateField id="dfdApplyTime" styleName="formItemCSS" formatString="YYYY-MM-DD" dayNames="[日,一,二,三,四,五,六]" monthNames="[一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二

Python日期时间操作函数详解

处理日志数据时,经常要对日期进行进行计算,比如日期加上天数.日期相差天数.日期对应的周等计算,本文收集了几个常用的python日期功能函数,一直更新中. 直接贴代码(文件名DateUtil.py),函数功能可以直接查看注释:  代码如下 复制代码 # -*- encoding:utf8 -*- ''' @author: crazyant @version: 2013-10-12 ''' import datetime, time #定义的日期的格式,可以自己改一下,比如改成"$Y年$m月$d日&

Dart的日期时间操作

当前时间 main(List<String> arguments) { //创建时间对象,获取当前时间 DateTime now = new DateTime.now(); print("当前时间:$now"); } 输出效果如下 指定时间 main(List<String> arguments) { //创建时间对象,并指定时间 DateTime victoryDay = new DateTime(1945,9,9); print("日本于${vic

一个特牛的日期时间判断正则表达式

这里是判断YYYY-MM-DD这种格式的,基本上把闰年和2月等的情况都考虑进去了,不过我已经忘了在哪里找到的. ^((((1[6-9]|[2-9]d)d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]d|3[01]))|(((1[6-9]|[2-9]d)d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]d|30))|(((1[6-9]|[2-9]d)d{2})-0?2-(0?[1-9]|1d|2[0-8]))|(((1[6-9]|[2-9]

一个特牛的日期时间判断正则表达式_正则表达式

这里是判断YYYY-MM-DD这种格式的,基本上把闰年和2月等的情况都考虑进去了,不过我已经忘了在哪里找到的.  ^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[

Python与SQLite日期时间函数的使法

SQLite的时间函数跟Python的时间函数有些许差别,所以稍做记录,供自己以后查询.     网上有将SQLite官方WIKI内容翻译成中文的文章,大家有兴趣可以搜索一下,我这里单纯记录一下个人比较常用的一些内容. SQLite的五个时间函数: date(日期时间字符串, 修正符, 修正符, ......) time(日期时间字符串, 修正符, 修正符, ......) datetime(日期时间字符串, 修正符, 修正符, ......) julianday(日期时间字符串, 修正符, 修

用&amp;#106avascript实现的日期时间输入控件

控件 在b/s程序设计中,经常需要向一个输入框输入日期或时间,并验证输入是否有效.通常的验证方法是在提交的时候进行字符串验证,如果是合法的日期时间则正常提交,否则取消提交并给出错误信息.或者,将日期时间的输入变成几个下拉列表框,由用户选择年月日时分秒. 这里给出一个用javascript编写的日期时间输入验证脚本.这个脚本可以使一个普通的输入框变成日期时间输入框.你只能在这个输入框里输入日期时间格式的字符串,而不允许你输入任何其他的字符.当你输入非法字符时,它并不是不负责任地弹出错误对话框,而是