RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.DecodeTime Function

Breaks a TDateTime value into hours, minutes, seconds, and milliseconds.

Pascal
procedure DecodeTime(const DateTime: TDateTime; var Hour: Word; var Min: Word; var Sec: Word; var MSec: Word);
C++
DecodeTime(const TDateTime DateTime, Word Hour, Word Min, Word Sec, Word MSec);

DecodeTime breaks the object specified as the Time parameter into hours, minutes, seconds, and milliseconds.  

C++ Examples: 

 

/*
This example uses a button and two labels on a form. When
the user clicks the button, the current date and time are
reported in the captions of the two labels.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  Word Year, Month, Day, Hour, Min, Sec, MSec;
  TDateTime dtPresent = Now();
  DecodeDate(dtPresent, Year, Month, Day);
  Label1->Caption = AnsiString("Today is Day ") + IntToStr(Day) + AnsiString(" of Month ") + IntToStr(Month) + AnsiString(" of Year ") + IntToStr(Year);
  DecodeTime(dtPresent, Hour, Min, Sec, MSec);
  Label2->Caption = AnsiString("The time is Minute ") + IntToStr(Min) + AnsiString(" of Hour ") + IntToStr(Hour);
}

 

Delphi Examples: 

{
This example uses a button and two labels on a form. When
the user clicks the button, the current date and time are
reported in the captions of the two labels.
}
procedure TForm1.Button1Click(Sender: TObject);
var
  Present: TDateTime;
  Year, Month, Day, Hour, Min, Sec, MSec: Word;
 begin
  Present:= Now;
  SysUtils.DecodeDate(Present, Year, Month, Day);
  Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
    + IntToStr(Month) + ' of Year ' + IntToStr(Year);
  SysUtils.DecodeTime(Present, Hour, Min, Sec, MSec);
  Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
    + IntToStr(Hour);
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!