Sign in Join
FPDoc Onlineexperiment

RecodeHour function

In unit DateUtils

Replace hours part of a TDateTime value with another hour.

Declaration

pascal
function RecodeHour(const AValue: TDateTime; const AHour: Word)
: TDateTime

Arguments

AValue

Date/time to recode.

AHour

Hour to replace in AValue.

Function result

AValue with replaced hour.

Description

RecodeHour replaces the Hour part of the timestamp AValue with AHour. All other parts of the date/time stamp are left untouched.

Errors

If the AHour value is not within a valid range (0..23) then an EConvertError exception is raised.

See also

Example: ex90

pascal
Program Example90;

{ This program demonstrates the RecodeHour function }

Uses SysUtils,DateUtils;

Const
  Fmt = 'dddd dd mmmm yyyy hh:nn:ss';

Var
  S : AnsiString;

Begin
  S:=FormatDateTime(Fmt,RecodeHour(Now,0));
  Writeln('Today, in the first hour : ',S);
End.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.