Sign in Join
FPDoc Onlineexperiment

RecodeSecond function

In unit DateUtils

Replace seconds part of a TDateTime value with another second.

Declaration

pascal
function RecodeSecond(const AValue: TDateTime; const ASecond: Word)
: TDateTime

Arguments

AValue

Date/time to recode.

ASecond

Second to replace in AValue.

Function result

AValue with replaced second.

Description

RecodeSecond replaces the Second part of the timestamp AValue with ASecond. All other parts of the date/time stamp are left untouched.

Errors

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

See also

Example: ex92

pascal
Program Example92;

{ This program demonstrates the RecodeSecond function }

Uses SysUtils,DateUtils;

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

Var
  S : AnsiString;

Begin
  S:=FormatDateTime(Fmt,RecodeSecond(Now,0));
  Writeln('This moment, seconds stripped : ',S);
End.

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