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

TryEncodeDateTime

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

Declaration

Source position: dateutil.inc line 303

function TryEncodeDateTime(

  const AYear: Word;

  const AMonth: Word;

  const ADay: Word;

  const AHour: Word;

  const AMinute: Word;

  const ASecond: Word;

  const AMilliSecond: Word;

  var 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 TDateTimevalue.

Function result

Trueif the encoding was succesful

Description

EncodeDateTimeencodes the values AYearAMonth, ADay,AHour, AMinute,ASecondand AMilliSecondto a date/time valueand returns this value in AValue.

If the date was encoded succesfully, Trueis returned, Falseis returned if one of the arguments is not valid.

See also

EncodeDateTime

  

Encodes a DateTime value from all its parts

EncodeDateMonthWeek

  

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

EncodeDateWeek

  

Encode a TDateTimevalue from a year, week and day of week triplet

EncodeDateDay

  

Encodes a year and day of year to a DateTime value

TryEncodeDateDay

  

Encode a year and day of year to a TDateTimevalue

TryEncodeDateWeek

  

Encode a year, week and day of week triplet to a TDateTimevalue

TryEncodeDateMonthWeek

  

Encode a year, month, week of month and day of week to a TDateTimevalue

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.