⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 esbdates.pas

📁 好用的日期转换函数 Date/Time Routines to enhance your 32-bit Delphi Programming.
💻 PAS
📖 第 1 页 / 共 5 页
字号:
function Secs2Hrs (const Value: Extended): Extended;

{: Returns the number of Seconds the specified number of Hours represents.
	@param Value Number of Hours
	@returns the Number of Seconds
	@cat DTConv
}
function Hrs2Secs (const Value: Extended): Extended;

{: Returns the number of Minutes the specified number of Days represents.
	@param Value Number of Days
	@returns the Number of Minutes
	@cat DTConv
}
function Days2Mins (const Value: Extended): Extended;

{: Returns the number of Days the specified number of Minutes represents.
	@param Value Number of Minutes
	@returns the Number of Days
	@cat DTConv
}
function Mins2Days (const Value: Extended): Extended;

{: Returns the number of Weeks the specified number of Days represents.
	@param Value Number of Days
	@returns the Number of Weeks
	@cat DTConv
}
function Days2Weeks (const Value: Extended): Extended;

{: Returns the number of Days the specified number of Weeks represents.
	@param Value Number of Weeks
	@returns the Number of Days
	@cat DTConv
}
function Weeks2Days (const Value: Extended): Extended;

{: Returns the number of Fortnights the specified number of Days represents.
	@param Value Number of Days
	@returns the Number of Fortnights
	@cat DTConv
}
function Days2Fortnights (const Value: Extended): Extended;

{: Returns the number of Days the specified number of Fortnights represents.
	@param Value Number of Fortnights
	@returns the Number of Days
	@cat DTConv
}
function Fortnights2Days (const Value: Extended): Extended;

{: Returns the number of Months the specified number of Days represents. Months
	are based on Synodic Months - see <See Const=DaysPerSynodicMonth>.
	@param Value Number of Days
	@returns the Number of Months
	@cat DTConv
}
function Days2Months (const Value: Extended): Extended;

{: Returns the number of Days the specified number of Months represents.  Months
	are based on Synodic Months - see <See Const=DaysPerSynodicMonth>.
	@param Value Number of Months (Synodic)
	@returns the Number of Days
	@cat DTConv
}
function Months2Days (const Value: Extended): Extended;

{: Returns the number of Years the specified number of Days represents. Years
	are based on Tropical Years - see <See Const=DaysPerTropicalYear>.
	@param Value Number of Days
	@returns the Number of Years (Tropical)
	@cat DTConv
}
function Days2Years (const Value: Extended): Extended;

{: Returns the number of Days the specified number of Years represents.  Months
	are based on Tropical years - see <See Const=DaysPerTropicalYear>.
	@param Value Number of Years (Tropical)
	@returns the Number of Days
	@cat DTConv
}
function Years2Days (const Value: Extended): Extended;

{: Returns the number of Years the specified number of Days represents. Years
	are based on Gregorian Years - see <See Const=DaysPerGregorianYear>.
	@param Value Number of Days
	@returns the Number of Years (Gregorian)
	@cat DTConv
}
function Days2YearsGregorian (const Value: Extended): Extended;

{: Returns the number of Days the specified number of Years represents.  Months
	are based on Gregorian years - see <See Const=DaysPerGregorianYear>.
	@param Value Number of Years (Gregorian)
	@returns the Number of Days
	@cat DTConv
}
function YearsGregorian2Days (const Value: Extended): Extended;

{: Returns the number of Years the specified number of Days represents. Years
	are based on Julian Years - see <See Const=DaysPerJulianYear>.
	@param Value Number of Days
	@returns the Number of Years (Julian)
	@cat DTConv
}
function Days2YearsJulian (const Value: Extended): Extended;

{: Returns the number of Days the specified number of Years represents.  Months
	are based on Julian years - see <See Const=DaysPerJulianYear>.
	@param Value Number of Years (Julian)
	@returns the Number of Days
	@cat DTConv
}
function YearsJulian2Days (const Value: Extended): Extended;

{: Converts a quantity of seconds into a String of the form 'h:mm:ss'.
	Routine proposed by Joel Joly.
	@cat DTConv
}
function Sec2TimeStr (Sec : LongInt): string;

//--- Date/Time Arithmetic ---

{: Returns the number of whole minutes apart the two times are (date portion ignored)
	and DT1 is assumed to be before DT2.
	@param DT1 First Time, Date portion ignores - assumed to be the earlier time.
	@param DT2 Second Time, Date portion ignores - assumed to be the later time.
	@cat DTMath
}
function MinutesApart (const DT1, DT2: TDateTime): Word;

{: Returns the decimal number of Days apart the two date/times are. If 0 then
	they are the same Date/Time, if negative then DT1 occurs after DT2 DT2.
	@param DT1 First Date/Time to process.
	@param DT2 Second DateTime to process.
	@cat DTMath
}
function TimeApartInDays (const DT1, DT2: TDateTime): Extended;

{: Returns the decimal number of Weeks apart the two date/times are. If 0 then
	they are the same Date/Time, if negative then DT1 occurs after DT2 DT2.
	@param DT1 First Date/Time to process.
	@param DT2 Second DateTime to process.
	@cat DTMath
}
function TimeApartInWeeks (const DT1, DT2: TDateTime): Extended;

{: Returns the decimal number of fortnights apart the two date/times are. If 0 then
	they are the same Date/Time, if negative then DT1 occurs after DT2 DT2.
	@param DT1 First Date/Time to process.
	@param DT2 Second DateTime to process.
	@cat DTMath
}
function TimeApartInFortnights (const DT1, DT2: TDateTime): Extended;

{: Returns the decimal number of hours apart the two date/times are. If 0 then
	they are the same Date/Time, if negative then DT1 occurs after DT2 DT2.
	@param DT1 First Date/Time to process.
	@param DT2 Second DateTime to process.
	@cat DTMath
}
function TimeApartInHrs (const DT1, DT2: TDateTime): Extended;

{: Returns the decimal number of Minutes apart the two date/times are. If 0 then
	they are the same Date/Time, if negative then DT1 occurs after DT2 DT2.
	@param DT1 First Date/Time to process.
	@param DT2 Second DateTime to process.
	@cat DTMath
}
function TimeApartInMins (const DT1, DT2: TDateTime): Extended;

{: Returns the decimal number of Seconds apart the two date/times are. If 0 then
	they are the same Date/Time, if negative then DT1 occurs after DT2 DT2.
	@param DT1 First Date/Time to process.
	@param DT2 Second DateTime to process.
	@cat DTMath
}
function TimeApartInSecs (const DT1, DT2: TDateTime): Extended;

{: Converts a time in MilliSeconds to a string of the form 'H:MM:SS.mmm'.
	@param MS Value in Milliseconds.
	@cat DTMath
}
function MS2TimeStr (const MS: LongInt): String;

{: Returns the current date/time as a string in the Format of: YYYYMMDD-HHMMSSmmm.
	@cat DTMath
}
function GetDateTimeStamp: String;

{: Adjusts the date so that it has the Year specified. Makes 29 Feb of any
	year that is not a Leap year 1 Mar.
	@param D Date/Time to process.
	@param Year Year to make the date in, eg 1999.
	@cat DTMath
	@cat YearMath
}
function AdjustDateYear (const D: TDateTime; const Year: Word): TDateTime;

{: Adds a Floating Point amount of Seconds to a Given Date/Time.
	@param DT Date/Time to process.
	@param Secs Number of Seconds to Add - can be negative.
	@cat DTMath
}
function AddSecs (const DT: TDateTime; const Secs: Extended): TDateTime;

{: Adds a Floating Point amount of Minutes to a Given Date/Time.
	@param DT Date/Time to process.
	@param Mins Number of Minutes to Add - can be negative.
	@cat DTMath
}
function AddMins (const DT: TDateTime; const Mins: Extended): TDateTime;

{: Adds a Floating Point amount of Hours to a Given Date/Time.
	@param DT Date/Time to process.
	@param Hrss Number of Hours to Add - can be negative.
	@cat DTMath
}
function AddHrs (const DT: TDateTime; const Hrs: Extended): TDateTime;

{: Adds a Floating Point amount of Days to a Given Date/Time.
	Though this is the same as normal Addition it is added for completion.
	@param DT Date/Time to process.
	@param Dayss Number of Days to Add - can be negative.
	@cat DTMath
}
function AddDays (const DT: TDateTime; const Days: Extended): TDateTime;

{: Adds a Floating Point amount of Weeks to a Given Date/Time.
	@param DT Date/Time to process.
	@param Weeks Number of Weeks to Add - can be negative.
	@cat DTMath
	@cat WeekMath
}
function AddWeeks (const DT: TDateTime; const Weeks: Extended): TDateTime;

{: Adds a Floating Point amount of Fortnights to a Given Date/Time.
	@param DT Date/Time to process.
	@param Fortnights Number of Fortnights to Add - can be negative.
	@cat DTMath
}
function AddFortnights (const DT: TDateTime; const FNights: Extended): TDateTime;

{: Adds a Floating Point amount of Months to a Given Date/Time.
	Fractional portion of Month is assumed to be related to 30 day months.
	Time portion preserved.<p>

	If adding Months results in landing on a nonsense date like 31 Apr
	then the last day in the month is used. This only applies to the
	integral component of the Months Added. The fractional part always
	is added to the resultant Date/Time.

	@param DT Date/Time to process.
	@param Months Number of Months to Add - can be negative.
	@cat DTMath
	@cat MonthMath
}
function AddMonths (const DT: TDateTime; const Months: Extended): TDateTime;

{: Adds a Floating Point amount of Quarters to a Given Date/Time.
	Fractional portion of Quarter is assumed to be related to 30 day month,
	as the AddMonths routine is used.
	Time portion preserved. <p>

	If adding Quarters results in landing on a nonsense date like 31 Apr
	then the last day in the month is used. This only applies to the
	integral component of the Quarter Added. The fractional part always
	is added to the resultant Date/Time.

	@param DT Date/Time to process.
	@param Qtrs Number of Quarters to Add - can be negative.
	@cat DTMath
}
function AddQuarters (const DT: TDateTime; const Qtrs: Extended): TDateTime;

{: Adds a Floating Point amount of Semesters to a Given Date/Time.
	Fractional portion of Semester is assumed to be related to 30 day month,
	as the AddMonths routine is used.
	Time portion preserved.<p>

	If adding Semesters results in landing on a nonsense date like 31 Apr
	then the last day in the month is used. This only applies to the
	integral component of the Semeters Added. The fractional part always
	is added to the resultant Date/Time.

	@param DT Date/Time to process.
	@param Sems Number of Semesters to Add - can be negative.
	@cat DTMath
}
function AddSemesters (const DT: TDateTime; const Sems: Extended): TDateTime;

{: Adds a Floating Point amount of Years to a Given Date/Time.
	Fractional portion of Year is assumed to be related to 365.25 day years.
	Time portion preserved.<p>

	If Adding Years results in landing on Feb 29 in a non-leap year, then
	this will be converted to Feb 28.This only applies to the
	integral component of the Years Added. The fractional part always
	is added to the resultant Date/Time.

	@param DT Date/Time to process.
	@param Yrs Number of Years to Add - can be negative.
	@cat DTMath
	@cat YearMath
}
function AddYrs (const DT: TDateTime; const Yrs: Extended): TDateTime;

{: Subtracts a Floating Point amount of Seconds from a Given Date/Time.
	@param DT Date/Time to process.
	@param Secs Number of Seconds to Subtract - can be negative.
	@cat DTMath
}
function SubtractSecs (const DT: TDateTime; const Secs: Extended): TDateTime;

{: Subtracts a Floating Point amount of Minutes from a Given Date/Time.
	@param DT Date/Time to process.
	@param Mins Number of Minutes to Subtract - can be negative.
	@cat DTMath
}
function SubtractMins (const DT: TDateTime; const Mins: Extended): TDateTime;

{: Subtracts a Floating Point amount of Hours from a Given Date/Time.
	@param DT Date/Time to process.
	@param Hrs Number of Hours to Subtract - can be negative.
	@cat DTMath
}
function SubtractHrs (const DT: TDateTime; const Hrs: Extended): TDateTime;

{: Subtracts a Floating Point amount of Days from a Given Date/Time.
	@param DT Date/Time to process.
	@param Days Number of Days to Subtract - can be negative.
	@cat DTMath
}
function SubtractDays (const DT: TDateTime; const Days: Extended): TDateTime;

{: Subtracts a Floating Point amount of Weeks from a Given Date/Time.
	@param DT Date/Time to process.
	@param Weeks Number of Weeks to Subtract - can be negative.
	@cat DTMath
	@cat WeekMath
}
function SubtractWeeks (const DT: TDateTime; const Weeks: Extended): TDateTime;

{: Subtracts a Floating Point amount of Fortnights from a Given Date/Time.
	@param DT Date/Time to process.
	@param Fortnights Number of Fortnights to Subtract - can be negative.
	@cat DTMath
}
function SubtractFortnights (const DT: TDateTime; const FNights: Extended): TDateTime;

{: Subtracts a Floating Point amount of Months from a Given Date/Time.
	Fractional portion of Month is assumed to be related to 30 day months.
	Time portion preserved. <p>

	If Subtracting Months results in landing on a nonsense date like 31 Apr
	then the last day in the month is used. This only applies to the
	integral component of the Months Subtracted. The fractional part always
	is Subtracted from the resultant Date/Time.

	@param DT Date/Time to process.
	@param Months Number of Months to Subtract - can be negative.
	@cat DTMath
	@cat MonthMath
}
function SubtractMonths (const DT: TDateTime; const Months: Extended): TDateTime;

{: Subtracts a Floating Point amount of Quarters from a Given Date/Time.
	Fractional portion of Quarter is assumed to be related to 30 day month,
	as the AddMonths routine is used. Time portion preserved.<p>

	If Subtracting Quarters results in landing on a nonsense date like 31 Apr
	then the last day in the month is used. This only applies to the
	integral component of the Quarter Subtracted. The fractional part always
	is Subtracted from the resultant Date/Time.

	@param DT Date/Time to process.
	@param Qtrs Number of Quarters to Subtract - can be negative.
	@cat DTMath
}
function SubtractQuarters (const DT: TDateTime; const Qtrs: Extended): TDateTime;

{: Subtracts a Floating Point amount of Semesters from a Given Date/Time.
	Fractional portion of Semester is assumed to be related to 30 day month,
	as the AddMonths routine is used. Time portion preserved.<p>

	If Subtracting Semesters results in landing on a nonsense date like 31 Apr
	then the last day in the month is used. This only applies to the
	integral component of the Semeters Subtracted. The fractional part always
	is Subtracted from the resultant Date/Time.

	@param DT Date/Time to process.
	@param Sems Number of Semesters to Subtract - can be negative.
	@cat DTMath
}
function SubtractSemesters (const DT: TDateTime; const Sems: Extended): TDateTime;

{: Subtracts a Floating Point amount of Years from a Given Date/Time.
	Fractional portion of Year is assumed to be related to 365.25 day years.
	Time portion preserved.<p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -