为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

Delphi编程自定义的时间日期函数大集合

2017-08-31 11页 doc 32KB 16阅读

用户头像

is_348501

暂无简介

举报
Delphi编程自定义的时间日期函数大集合Delphi编程自定义的时间日期函数大集合 //--- 年度函数 --- //检查日期值是否是润年 function IsLeapYear (Year: Word): Boolean; //传回日期值年度的第一天 function GetFirstDayOfYear (const Year: Word): TDateTime; //传回日期值年度的最后一天 function GetLastDayOfYear (const Year: Word): TDateTime; //传回日期值年度的第一星期天的日期 func...
Delphi编程自定义的时间日期函数大集合
Delphi编程自定义的时间日期#数#大集合 //--- 年度函数 --- //检查日期值是否是润年 function IsLeapYear (Year: Word): Boolean; //传回日期值年度的第一天 function GetFirstDayOfYear (const Year: Word): TDateTime; //传回日期值年度的最后一天 function GetLastDayOfYear (const Year: Word): TDateTime; //传回日期值年度的第一星期天的日期 function GetFirstSundayOfYear (const Year: Word): TDateTime; //传回西洋日期的MM/DD/YY function GetMDY (const DT: TDateTime): String; //--- 日期型的转换 --- //日期转成字符串 //如果是错误将传一空值 function Date2Str (const DT: TDateTime): String; //传回日期值的日期 function GetDay (const DT: TDateTime): Word; //:传回日期值的月份 function GetMonth (const DT: TDateTime): Word; //: 传回日期值的年份 function GetYear (const DT: TDateTime): Word; //:将日期的值取出时间的值 function Time2Hr (const DT: TDateTime): Word; //:将日期的值取出分锺的值 function Time2Min (const DT: TDateTime): Word; //:将日期的值取出秒数的值 function Time2Sec (const DT: TDateTime): Word; //:将日期的值取出微秒的值 function Time2MSec (const DT: TDateTime): Word; //传回目前的年度 function ThisYear: Word; //传回目前的月份 function ThisMonth: Word; //传回目前的日期 function ThisDay: Word; //传回目前的时间 function ThisHr: Word; //传回目前的分锺 function ThisMin: Word; //传回目前的秒数 function ThisSec: Word; //将英文的星期转成整数值 //例如EDOWToInt(''SUNDAY')=1 function EDOWToInt (const DOW: string): Integer; //将英文的月份转成整数值的月 //例如EMonthToInt('JANUARY')=1 function EMonthToInt (const Month: string): Integer; function GetCMonth(const DT: TDateTime): String; //传回中文显示的月份 function GetC_Today: string; //传回中国的日期 //例如: GetC_Today传回值为89/08/11 Function TransC_DateToE_Date(Const CDT :String) :TDateTime; //将民国的年月日转换为公元的YYYY/MM/DD //2001/02/02加入 例如:TransC_DateToE_Date('90年2月1日')传回值是2001/2/1 function GetCWeek(const DT: TDateTime): String; //传回值为中文显示的星期 例如:GETCWeek(2000/08/31)=星期四 function GetLastDayForMonth(const DT: TDateTime):TDateTime; //传回本月的最后一天 function GetFirstDayForMonth (const DT :TDateTime): TDateTime; //取得月份的第一天 function GetLastDayForPeriorMonth(const DT: TDateTime):TDateTime; //传回上个月的最后一天 function GetFirstDayForPeriorMonth (const DT :TDateTime): TDateTime; //取得上个月份的第一天 function ROCDATE(DD:TDATETIME;P:integer):string; {转换某日期为民国0YYMMDD 型式字符串,例如:ROCDATE(Now,0)='900304' } {P=0 不加'年'+'月'+'日'} {P=1 加'年'+'月'+'日'} {------------------- 日期和时间的计算函数------------------} //传回两个日期相减值的分锺数 function MinutesApart (const DT1, DT2: TDateTime): Word; //调整年度的时间 //例如AdjustDateYear(Now,1998)传回值为'1998/02/25' function AdjustDateYear (const D: TDateTime; const Year: Word): TDateTime; //增加n个分钟的时间 function AddMins (const DT: TDateTime; const Mins: Extended): TDateTime; //增加n个小时的时间 function AddHrs (const DT: TDateTime; const Hrs: Extended): TDateTime; //可将日期加上欲增加的天数为得到的值 例如:AddDays(2000/08/31,10)=2000/09/10 function AddDays (const DT: TDateTime; const Days: Extended): TDateTime; //增加n周的时间 //例如:AddWeeks(2001/01/21,2)传回值为'2001/02/4' function AddWeeks (const DT: TDateTime; const Weeks: Extended): TDateTime; //增加n个月的时间 function AddMonths (const DT: TDateTime; const Months: Extended): TDateTime; //增加n个年的时间 function AddYrs (const DT: TDateTime; const Yrs: Extended): TDateTime; //传回向前算的N个分锺 function SubtractMins (const DT: TDateTime; const Mins: Extended): TDateTime; //传回向前算的N个小时 function SubtractHrs (const DT: TDateTime; const Hrs: Extended): TDateTime; //传回向前算的N个天 function SubtractDays (const DT: TDateTime; const Days: Extended): TDateTime; //传回向前算的N个周 function SubtractWeeks (const DT: TDateTime; const Weeks: Extended): TDateTime; //传回向前算的N个月,例如:SubtractMonths('2000/11/21',3)传回'2000/08/22' function SubtractMonths (const DT: TDateTime; const Months: Extended): TDateTime; //传回日期值的本月份的最后一天 function GetLastDayOfMonth (const DT: TDateTime): TDateTime; //传回日期值的本月份的第一天 function GetFirstDayOfMonth (const DT: TDateTime): TDateTime; //传回年度第一周的第一个星期天的日期 function StartOfWeek (const DT: TDateTime): TDateTime; //传回年度最后一周的最后一个星期天的日期 function EndOfWeek (const DT: TDateTime): TDateTime; //将秒数转换为时分秒 function Hrs_Min_Sec (Secs: Extended): string; //: 比较两的日期值是否是同月如果是为真 function DatesInSameMonth (const DT1, DT2: TDateTime): Boolean; //: 比较两的日期值是否是同年如果是为真 function DatesInSameYear (const DT1, DT2: TDateTime): Boolean; //: 比较两的日期值是否是同年和同月如果是为真 function DatesInSameMonthYear (const DT1, DT2: TDateTime): Boolean; //:传回两个日期相减值的天数 //例如:DaysApart是DT2减DT1 function DaysApart (const DT1, DT2: TDateTime): LongInt; //传回两个日期相减值的周数 //例如:ExactWeeksApart是DT2减DT1 function ExactWeeksApart (const DT1, DT2: TDateTime): Extended; //传回两个日期相减值的周数 //例如:ExactWeeksApart是DT2减DT1 function WeeksApart (const DT1, DT2: TDateTime): LongInt; //: 如果是真示日期为润年 function DateIsLeapYear (const DT: TDateTime): Boolean; //: 传回日期值本月份的天数 // DaysThisMonth(Now)= 31,三月有31天 function DaysThisMonth (const DT: TDateTime): Byte; //: 传回日期值的本年度的月份中的日数,还有几天 //DaysLeftInMonth('2001/04/28')传回值2 function DaysLeftInMonth (const DT: TDateTime): Byte; //: 传回日期值的本年度的月份中的日数,还有几天 function DaysInMonth (const DT: TDateTime): Byte; //: 传回日期值的本年度的天数,如果是润年有366天;不是就有365天 function DaysInYear (const DT: TDateTime): Word; //: 传回日期值中本年度已过了几天 //例如:DayOfYear(now)=119 function DayOfYear (const DT: TDateTime): Word; //: 传回今天的日期在本年度过了几天 //例如: ThisDayOfYear=119 function ThisDayOfYear: Word; //:传回今年度还有几天 function DaysLeftInYear (const DT: TDateTime): Word; //传回日期值的季别 //例如:WhichQuarter(now)=2 function WhichQuarter (const DT: TDateTime): Byte; //传回年龄,依现在其日期减出生的日期 function AgeAtDate (const DOB, DT: TDateTime): Integer; //传回年龄,依现在其日期减出生的日期 function AgeNow (const DOB: TDateTime): Integer; //传回年龄,依现在其日期减出生的日期 function AgeAtDateInMonths (const DOB, DT: TDateTime): Integer; //传回年龄,依现在其日期减出生的日期 function AgeNowInMonths (const DOB: TDateTime): Integer; //传回日期值已存活的周数 //例如 AgeAtDateInWeeks('1963/06/24',Now)=1975 function AgeAtDateInWeeks (const DOB, DT: TDateTime): Integer; //传回日期值已存活的周数,不同的是此函数不用第二个参数是用上一个函数完成的 //例如 AgeNowInWeeks('1963/06/24')=1975 function AgeNowInWeeks (const DOB: TDateTime): Integer; //可传回几岁几月几周的详细年龄 function AgeNowDescr (const DOB: TDateTime): String; function CheckDate(const sCheckedDateString: string): boolean; //检查是否是中华民国的日期格式 //例如:CheckDate(DatetoStr(Now))=89/08/29,传回值是Boolean {----------------- 周数处理用函数 --------------------} //将日期值转换成周数 function DateToWeekNo (const DT: TDateTime): Integer; //比较两个日期值是否相同 function DatesInSameWeekNo (const DT1, DT2: TDateTime): Boolean; //将两个日期相减后转成周数 function WeekNosApart (const DT1, DT2: TDateTime): Integer; //传回目前日期的周数 function ThisWeekNo: Integer; //传回在X的年度的第n周的时间 //例如:GetWeekNoToDate(28,2001)='2001/07/08',取得值是从星期天开始 function GetWeekNoToDate_Sun (const WeekNo, Year: Word): TDateTime; //传回在X的年度的第n周的时间 //例如:GetWeekNoToDate(28,2001)='2001/07/08',取得值是从星期一开始 function GetWeekNoToDate_Mon (const WeekNo, Year: Word): TDateTime; //传回在X的年度的第n周的时间 //例如:DWYToDate(3,28,2001)='2001/07/10',取得值是强制从星期天开始的 function DWYToDate (const DOW, WeekNo, Year: Word): TDateTime; //将周数转换成月日格式 //例如:WeekNoToDate(35)传回08/26 function WeekNoToDate(Const Weekno : Word):TDateTime; {--- 检查确定日期函数 ---} //: 如果传回值是真表示目前是一月 function IsJanuary (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是二月 function IsFebruary (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是三月 function IsMarch (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是四月 function IsApril (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是五月 function IsMay (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是六月 function IsJune (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是七月 function IsJuly (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是八月 function IsAugust (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是九月 function IsSeptember (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是十月 function IsOctober (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是十一月 function IsNovember (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是十二月 function IsDecember (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是上午 function IsAM (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是下午 function IsPM (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是中午 function IsNoon (const DT: TDateTime): Boolean; //:如果传回值是真表示目前是夜晚 function IsMidnight (const DT: TDateTime): Boolean; //: 如果传回值是真表示目前是星期天 function IsSunday (const DT: TDateTime): Boolean; //: 如果日期值是星期一即为真 function IsMonday (const DT: TDateTime): Boolean; //: 如果日期值是星期二即为真 function IsTuesday (const DT: TDateTime): Boolean; //: 如果日期值是星期三即为真 function IsWednesday (const DT: TDateTime): Boolean; //: 如果日期值是星期四即为真 function IsThursday (const DT: TDateTime): Boolean; //: 如果日期值是星期五即为真 function IsFriday (const DT: TDateTime): Boolean; //: 如果日期值是星期六即为真 function IsSaturday (const DT: TDateTime): Boolean; //:如果日期值是星期六或日即为真 function IsWeekend (const DT: TDateTime): Boolean; //: 如果日期值是星期一至五即为真 function IsWorkDays (const DT: TDateTime): Boolean; function CheckLastDayOfMonth(DT : TDateTime) : Boolean; //检查是否是本月的最后一天
/
本文档为【Delphi编程自定义的时间日期函数大集合】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索