MonthDays:给出一个月的天数

2018-10-31

声明:const MonthDays : array [Boolean] of TDayTable =
((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));

描述:MonthDays常量是SysUtils单元中比较有用的部分,它给出了一个月有多少天。如果一个闰年(第一个数组参数Boolean为True)的2月分,它返回29。

begin
// 2000年2月份有多少天?
ShowMessage('Days in February 2000 = '+
IntToStr(MonthDays[IsLeapYear(2000)][2]));
end;

程序运行结果: Days in February 2000 = 29

阅读18