[Delphi (Object Pascal)] Delphi根据日期返回当月的天数 →→→→→进入此内容的聊天室

来自 , 2019-11-30, 写在 Delphi (Object Pascal), 查看 122 次.
URL http://www.code666.cn/view/1f418331
  1. function DaysInMonth(const ADateTime: TDateTime): Byte;
  2. const
  3.   cDaysPerMonth: array[1..12] of Byte =  // array of days in months
  4.     (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  5.   cMonthFeb = 2;            // month number of February
  6.   cDaysInLeapYearFeb = 29;  // number of days in February in leap year
  7. var
  8.   Month: Word;  // month component of specified date
  9. begin
  10.   Month := DateMonth(ADateTime);
  11.   Result := cDaysPerMonth[Month];
  12.   if (Month = cMonthFeb) and IsLeapYear(ADateTime) then
  13.     Result := cDaysInLeapYearFeb;
  14. end;
  15. //delphi/2170

回复 "Delphi根据日期返回当月的天数"

这儿你可以回复上面这条便签

captcha