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

TryEncodeDateTime

Encode a Year, Month, Day, Hour, minute, seconds, milliseconds tuplet to a TDateTime value

Declaration

Source position: dateutil.inc line 319

function TryEncodeDateTime(

  const AYear: Word;

  const AMonth: Word;

  const ADay: Word;

  const AHour: Word;

  const AMinute: Word;

  const ASecond: Word;

  const AMilliSecond: Word;

  out AValue: TDateTime

):Boolean;

Arguments

AYear

  

Year

AMonth

  

Month in year

ADay

  

Day in month

AHour

  

Hour of the day

AMinute

  

Minutes in the hour

ASecond

  

Seconds in the minute

AMilliSecond

  

Millisecond in the second

AValue

  

Encoded TDateTime value.

Function result

True if the encoding was successful

Description

EncodeDateTime encodes the values AYearAMonth, ADay,AHour, AMinute,ASecond and AMilliSecond to a date/time value and returns this value in AValue.

If the date was encoded successfully, True is returned, False is returned if one of the arguments is not valid.

See also

EncodeDateTime

  

Encodes a TDateTime value from all its parts

EncodeDateMonthWeek

  

Encodes a year, month, week of month and day of week to a TDateTime value

EncodeDateWeek

  

Encode a TDateTime value from a year, week and day of week triplet

EncodeDateDay

  

Encodes a year and day of year to a TDateTime value

TryEncodeDateDay

  

Encode a year and day of year to a TDateTime value

TryEncodeDateWeek

  

Encode a year, week and day of week triplet to a TDateTime value

TryEncodeDateMonthWeek

  

Encode a year, month, week of month and day of week to a TDateTime value

Example

Program Example79;

{ This program demonstrates the TryEncodeDateTime function }

Uses SysUtils,DateUtils;

Var
  Y,Mo,D,H,Mi,S,MS : Word;
  TS : TDateTime;

Begin
  DecodeDateTime(Now,Y,Mo,D,H,Mi,S,MS);
  If TryEncodeDateTime(Y,Mo,D,H,Mi,S,MS,TS) then
    Writeln('Now is : ',DateTimeToStr(TS))
  else
    Writeln('Wrong date/time indication');
End.

Documentation generated on: May 14 2021