Sign in Join
FPDoc Onlineexperiment

RecodeTime function

In unit DateUtils

Replace time part of a TDateTime value with another time.

Declaration

pascal
function RecodeTime(const AValue: TDateTime; const AHour: Word; 
 const AMinute: Word; const ASecond: Word; 
 const AMilliSecond: Word): TDateTime

Arguments

AValue

Date/time to recode.

AHour

Hour to replace in AValue.

AMinute

Minute to replace in AValue.

ASecond

Second to replace in AValue.

AMilliSecond

Millisecond to replace in AValue.

Function result

AValue with replaced time.

Description

RecodeTime replaces the time part of the timestamp AValue with the date specified in AHour, AMinute, ASecond and AMilliSecond. All other parts (the date part) of the date/time stamp are left untouched.

Errors

If one of the values AHour, AMinute, ASecond AMilliSecond is not within a valid range then an EConvertError exception is raised.

See also

Example: ex95

pascal
Program Example95;

{ This program demonstrates the RecodeTime function }

Uses SysUtils,DateUtils;

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

Var
  S : AnsiString;

Begin
  S:=FormatDateTime(Fmt,RecodeTime(Now,8,0,0,0));
  Writeln('Today, 8 AM : ',S);
End.

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