Unit 'DateUtils' Package
[Overview][Constants][Classes][Procedures and functions][Index] [#rtl]

TryRecodeDateTime

Replace selected parts of a TDateTime value with other values.

Declaration

Source position: dateutil.inc line 377

function TryRecodeDateTime(

  const AValue: TDateTime;

  const AYear: Word;

  const AMonth: Word;

  const ADay: Word;

  const AHour: Word;

  const AMinute: Word;

  const ASecond: Word;

  const AMilliSecond: Word;

  out AResult: TDateTime

):Boolean;

Arguments

AValue

  

Date/time to recode.

AYear

  

New value for year part.

AMonth

  

New value for month part.

ADay

  

New value for day part.

AHour

  

New value for hour part.

AMinute

  

New value for minute part.

ASecond

  

New value for second part.

AMilliSecond

  

New value for millisecond part.

AResult

  

Recoded AValue.

Function result

True if the recoding was successful, False if not.

Description

TryRecodeDateTime replaces selected parts of the timestamp AValue with the date/time values specified in AYear, AMonth, ADay, AHour, AMinute, ASecond and AMilliSecond. If any of these values equals the predefined constant RecodeLeaveFieldAsIs, then the corresponding part of the date/time stamp is left untouched.

The resulting date/time is returned in AValue.

The function returns True if the encoding was successful. It returns False if one of the values AYear, AMonth, ADay, AHour, AMinute, ASecondAMilliSecond is not within a valid range.

See also

RecodeYear

  

Replace year part of a TDateTime value with another year.

RecodeMonth

  

Replace month part of a TDateTime value with another month.

RecodeDay

  

Replace day part of a TDateTime value with another day.

RecodeHour

  

Replace hours part of a TDateTime value with another hour.

RecodeMinute

  

Replace minutes part of a TDateTime value with another minute.

RecodeSecond

  

Replace seconds part of a TDateTime value with another second.

RecodeMilliSecond

  

Replace milliseconds part of a TDateTime value with another millisecond.

RecodeDate

  

Replace date part of a TDateTime value with another date.

RecodeTime

  

Replace time part of a TDateTime value with another time.

RecodeDateTime

  

Replace selected parts of a TDateTime value with other values.

Example

Program Example97;

{ This program demonstrates the TryRecodeDateTime function }

Uses SysUtils,DateUtils;

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

Var
  S : AnsiString;
  D : TDateTime ;

Begin
  If TryRecodeDateTime(Now,2000,2,RecodeLeaveFieldAsIs,0,0,0,0,D) then
    begin
    S:=FormatDateTime(Fmt,D);
    Writeln('This moment in februari 2000 : ',S);
    end
  else
    Writeln('This moment did/does not exist in februari 2000');
End.

Documentation generated on: Nov 23 2024