📄 esbdates.pas
字号:
ISO-8601 Week No Routines.
@param Year 4-digit year such as 1999.
@cat DTMath
@cat WeekMath
@cat YearMath
}
function GetFirstMondayOfYear (const Year: Word): TDateTime;
{: Returns the Start of the week containing given Date/Time, assumes that
the Start of the Week is Monday according to ISO-8601
- Time portion preserved.
@param DT Date to process.
@cat DTMath
@cat WeekMath
}
function StartOfISOWeek (const DT: TDateTime): TDateTime;
{: Returns the End of the week containing given Date/Time, assumes that
the End of the Week is Sunday according to ISO-8601
- Time portion preserved.
@param DT Date to process.
@cat DTMath
@cat WeekMath
}
function EndOfISOWeek (const DT: TDateTime): TDateTime;
{: Converts Dates into a Week No and Year according to ISO-8601. Weeks are
assumed to start with Monday. The week that Jan 4 occurs in is the 1st week of
the year. Note that this does mean that there can be 53 weeks in a year!
@param DT Date to process.
@param WeekNo Returns the ISO-8601 Week Number in specified Year
@param Year Returns 4 digit year to which the Week Number applies, not
necessarily the same year as DT.
@cat DTMath
@cat WeekMath
}
procedure Date2ISOWeekNo (const DT: TDateTime; var WeekNo: Byte;
var Year: Word);
{: Returns Date as a Basic Format for ISO Calendar Week/Day: YYYYWwwD where
YYYY is year, 'W' is literal, ww is weekno and D is the ISO Day of Week -
Monday is First Day.
@param DT Date to take year from.
@cat WeekMath
@cat DTConv
}
function Date2ISOWeekStr (const DT: TDateTime): string;
{: Returns Date as a Enhanced Format for ISO Calendar Week/Day: YYYY-Www-D where
YYYY is year, 'W' is literal, ww is weekno and D is the ISO Day of Week -
Monday is First Day.
@param DT Date to process.
@cat WeekMath
@cat DTConv
}
function Date2ISOWeekEnhStr (const DT: TDateTime): string;
{: Returns Date as a Basic Format for ISO Calendar Week: YYYYWww where
YYYY is year, 'W' is literal, ww is weekno.
@param DT Date to process.
@cat WeekMath
@cat DTConv
}
function Date2ISOWeekOnlyStr (const DT: TDateTime): string;
{: Returns Date as a Enhanced Format for ISO Calendar Week: YYYY-Www where
YYYY is year, 'W' is literal, ww is weekno.
@param DT Date to process.
@cat WeekMath
@cat DTConv
}
function Date2ISOWeekOnlyEnhStr (const DT: TDateTime): string;
{: Returns Date as a Basic Format for ISO Dates: YYYYMMDD where
YYYY is year, MM is the Month, DD is Day of Month. Zero Padded.
@param DT Date to process.
@cat DTConv
}
function Date2ISOStr (const DT: TDateTime): string;
{: Returns Date as a Basic Format for ISO Dates: YYYY-MM-DD where
YYYY is year, MM is the Month, DD is Day of Month. Zero Padded.
@param DT Date to process.
@cat DTConv
}
function Date2ISOEnhStr (const DT: TDateTime): string;
{: Returns Date as a Basic Format for ISO Dates: YYYYMMDD where
YYYY is year, MM is the Month, DD is Day of Month. Zero Padded.
@param DT Date to process.
@cat DTConv
}
function Date2ISOInt (const DT: TDateTime): Cardinal;
{Returns true if the two Dates are in the same ISO-8601 WeekNo.
@param DT1 First Date to process.
@param DT2 Second Date to process.
@cat DTMath
@cat WeekMath
@cat DTComparison
}
function DatesInSameISOWeekNo (const DT1, DT2: TDateTime): Boolean;
{Returns true No of Weeks, based on ISOWeekNo, that the two dates are
apart. A Negative result implies DT2 occurs before D1.
@param DT1 First Date to process.
@param DT2 Second Date to process.
@cat DTMath
@cat WeekMath
}
function ISOWeekNosApart (DT1, DT2: TDateTime): Integer;
{: Returns the ISO-8601 WeekNo of the current Date (System Date).
@param WeekNo Returns the ISO-8601 Week Number in specified Year
@param Year Returns 4 digit year to which the Week Number applies.
@cat DTMath
@cat WeekMath
}
procedure ThisISOWeekNo (var WeekNo: Byte; var Year: Word);
{: Returns the Start of the Week for the given ISO-8601 WeekNo in the given
year. Note that the Start of the Week is Monday in ISO-8601.
@param WeekNo Returns the ISO-8601 Week Number in specified Year
@param Year Returns 4 digit year to which the Week Number applies.
@cat DTMath
@cat WeekMath
}
function StartOfISOWeekNo (const WeekNo, Year: Word): TDateTime;
{: Returns the End of the Week for the given ISO-8601 WeekNo in the given
year. Note that the End of the Week is Sunday in ISO-8601.
@param WeekNo Returns the ISO-8601 Week Number in specified Year.
@param Year Returns 4 digit year to which the Week Number applies.
@cat DTMath
@cat WeekMath
}
function EndOfISOWeekNo (const WeekNo, Year: Word): TDateTime;
{: Returns the Date for a given Day of Week, a given WeekNo, and the given Year,
as defined in ISO-8601. Note that the Start of the Week is Monday, and
that DOW uses 1 for Monday.
@param Year 4 digit year to which the Week Number applies.
@param WeekNo the ISO-8601 Week Number in specified Year.
@param DOW Day of Week, 1 for Monday through 7 for Sunday.
@cat DTMath
@cat WeekMath
}
function ISOYWD2Date (const Year: Word; const WeekNo, DOW: Byte): TDateTime;
//--- Boolean Identification ---
{: Returns True if they are both the same Date ignoring the Time portion.
@param DT1 First Date to process.
@param DT2 Second Date to process.
@cat DTComparison
}
function SameDate (const DT1, DT2: TDateTime): Boolean;
{: Returns True if they are both the same Time ignoring the Date portion.
Times are considered the same if they are less then 1 millisecond apart.
@param DT1 First Time to process.
@param DT2 Second Time to process.
@cat DTComparison
}
function SameTime (const DT1, DT2: TDateTime): Boolean;
{: Returns True if they are both the same Date/Time. Date/Times are considered
the same if they are less then 1 millisecond apart.
@param DT1 First Date/Time to process.
@param DT2 Second Date/Time to process.
@cat DTComparison
}
function SameDateTime (const DT1, DT2: TDateTime): Boolean;
{: Returns True if the given Date's Month is January.
@param DT Date to process.
@cat DTComparison
}
function IsJanuary (const DT: TDateTime): Boolean;
{: Returns True if today's Month is January.
@cat DTComparison
}
function IsJanuaryNow: Boolean;
{: Returns True if the given Date's Month is February.
@param DT Date to process.
@cat DTComparison
}
function IsFebruary (const DT: TDateTime): Boolean;
{: Returns True if today's Month is February.
@cat DTComparison
}
function IsFebruaryNow: Boolean;
{: Returns True if the given Date's Month is March.
@param DT Date to process.
@cat DTComparison
}
function IsMarch (const DT: TDateTime): Boolean;
{: Returns True if today's Month is March.
@cat DTComparison
}
function IsMarchNow: Boolean;
{: Returns True if the given Date's Month is April.
@param DT Date to process.
@cat DTComparison
}
function IsApril (const DT: TDateTime): Boolean;
{: Returns True if today's Month is April.
@cat DTComparison
}
function IsAprilNow: Boolean;
{: Returns True if the given Date's Month is May.
@param DT Date to process.
@cat DTComparison
}
function IsMay (const DT: TDateTime): Boolean;
{: Returns True if today's Month is May.
@cat DTComparison
}
function IsMayNow: Boolean;
{: Returns True if the given Date's Month is June.
@param DT Date to process.
@cat DTComparison
}
function IsJune (const DT: TDateTime): Boolean;
{: Returns True if today's Month is June.
@cat DTComparison
}
function IsJuneNow: Boolean;
{: Returns True if the given Date's Month is July.
@param DT Date to process.
@cat DTComparison
}
function IsJuly (const DT: TDateTime): Boolean;
{: Returns True if today's Month is July.
@cat DTComparison
}
function IsJulyNow: Boolean;
{: Returns True if the given Date's Month is August.
@param DT Date to process.
@cat DTComparison
}
function IsAugust (const DT: TDateTime): Boolean;
{: Returns True if today's Month is August.
@cat DTComparison
}
function IsAugustNow: Boolean;
{: Returns True if the given Date's Month is September.
@param DT Date to process.
@cat DTComparison
}
function IsSeptember (const DT: TDateTime): Boolean;
{: Returns True if today's Month is September.
@cat DTComparison
}
function IsSeptemberNow: Boolean;
{: Returns True if the given Date's Month is October.
@param DT Date to process.
@cat DTComparison
}
function IsOctober (const DT: TDateTime): Boolean;
{: Returns True if today's Month is October.
@cat DTComparison
}
function IsOctoberNow: Boolean;
{: Returns True if the given Date's Month is November.
@param DT Date to process.
@cat DTComparison
}
function IsNovember (const DT: TDateTime): Boolean;
{: Returns True if today's Month is November.
@cat DTComparison
}
function IsNovemberNow: Boolean;
{: Returns True if the given Date's Month is December.
@param DT Date to process.
@cat DTComparison
}
function IsDecember (const DT: TDateTime): Boolean;
{: Returns True if todays Month is December.
@cat DTComparison
}
function IsDecemberNow: Boolean;
{: Returns True if the Time portion is a AM value.
@param DT Time to process.
@cat DTComparison
}
function IsAM (const DT: TDateTime): Boolean;
{: Returns True if the currnet Time is a AM value.
@cat DTComparison
}
function IsAMNow: Boolean;
{: Returns True if the Time portion is a PM value.
@param DT Time to process.
@cat DTComparison
}
function IsPM (const DT: TDateTime): Boolean;
{: Returns True if the current Time is a PM value.
@cat DTComparison
}
function IsPMNow: Boolean;
{: Returns True if the Time portion represents Noon, 12:00pm.
@param DT Time to process.
@cat DTComparison
}
function IsNoon (const DT: TDateTime): Boolean;
{: Returns True if the current Time represents Noon, 12:00pm.
@cat DTComparison
}
function IsNoonNow: Boolean;
{: Returns True if the Time portion represents Midnight, 12:00am.
@param DT Time to process.
@cat DTComparison
}
function IsMidnight (const DT: TDateTime): Boolean;
{: Returns True if the current Time represents Midnight, 12:00am.
@cat DTComparison
}
function IsMidnightNow: Boolean;
{: Returns True if the Date represents a Sunday.
@param DT Time to process.
@cat DTComparison
}
function IsSunday (const DT: TDateTime): Boolean;
{: Returns True if today is a Sunday.
@cat DTComparison
}
function IsSundayNow: Boolean;
{: Returns True if the Date represents a Monday.
@param DT Date to process.
@cat DTComparison
}
function IsMonday (const DT: TDateTime): Boolean;
{: Returns True if today is a Monday.
@cat DTComparison
}
function IsMondayNow: Boolean;
{: Returns True if the Date represents a Tuesday.
@param DT Date to process.
@cat DTComparison
}
function IsTuesday (const DT: TDateTime): Boolean;
{: Returns True if today is a Tuesday.
@cat DTComparison
}
function IsTuesdayNow: Boolean;
{: Returns True if the Date represents a Wednesday.
@param DT Date to process.
@cat DTComparison
}
function IsWednesday (const DT: TDateTime): Boolean;
{: Returns True if today is a Wednesday.
@cat DTComparison
}
function IsWednesdayNow: Boolean;
{: Returns True if the Date represents a Thursday.
@param DT Date to process.
@cat DTComparison
}
function IsThursday (const DT:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -