[Overview][Constants][Procedures and functions] Reference for unit 'dateutils' (#rtl)

RecodeTime

Replace time part of a TDateTimevalue with another time.

Declaration

Source position: dateutil.inc line 343

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

AValuewith replaced time.

Description

RecodeTimereplaces the time part of the timestamp AValuewith the date specified in AHour, AMinute, ASecondand AMilliSecond. All other parts (the date part) of the date/time stamp are left untouched.

Errors

If one of the values AHour, AMinute, ASecondAMilliSecondis not within a valid range then an EConvertErrorexception is raised.

See also

RecodeYear

  

Replace year part of a TDateTimevalue with another year.

RecodeMonth

  

Replace month part of a TDateTimevalue with another month.

RecodeDay

  

Replace day part of a TDateTimevalue with another day.

RecodeHour

  

Replace hours part of a TDateTimevalue with another hour.

RecodeMinute

  

Replace minutse part of a TDateTimevalue with another minute.

RecodeSecond

  

Replace seconds part of a TDateTimevalue with another second.

RecodeMilliSecond

  

Replace milliseconds part of a TDateTimevalue with another millisecond.

RecodeDate

  

Replace date part of a TDateTimevalue with another date.

RecodeDateTime

  

Replace selected parts of a TDateTimevalue with other values

Example

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.