System.DateUtils 3. IsPM、IsAM 判断是否为上、下午

编译版本:Delphi XE7

function IsPM(const AValue: TDateTime): Boolean; inline;
function IsAM(const AValue: TDateTime): Boolean;

implementation

// 判断是否为下午

function IsPM(const AValue: TDateTime): Boolean;
begin
  Result := HourOf(AValue) >= 12; // 判断时间数大于等于12点,即为下午
end;

// 判断是否为上午
function IsAM(const AValue: TDateTime): Boolean;
begin
  Result := not IsPM(AValue); // 不是下午即为上午 ^_^
end;

原文地址:https://www.cnblogs.com/BlackList-Sakura/p/4759957.html