function IsPM(const AValue: TDateTime): Boolean;
返回 True 表示下午 (12:00:00.000 至 23:59:59.999),False 表示上午。
uses DateUtils;
procedure TForm1.FormCreate(Sender: TObject);
var
t1, t2: TDateTime;
b1, b2: Boolean;
begin
t1 := EncodeDateTime(2009, 5, 21, 11, 22, 33, 999); // 上午
t2 := EncodeDateTime(2009, 5, 21, 12, 22, 33, 999); // 下午
b1 := IsPM(t1); // False
b2 := IsPM(t2); // True
ShowMessage(BoolToStr(b1, True)); // False
ShowMessage(BoolToStr(b2, True)); // True
end;
HourOf(t):獲取小時 (0-23),自行判斷 >= 12 同樣可行。IsAM:DateUtils 無此函數,可用 not IsPM(t)。