DTTry (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Language:

Description

 This example demonstrates the use of some routines in the DateUtils unit.

Code

void __fastcall TMainForm::btActionClick(TObject *Sender)
{
  TDateTime DateTime;
  if (rgActions->ItemIndex == 0)
    TryEncodeDateDay(StrToInt(edYear->Text),StrToInt(edDayYear->Text),DateTime);
  if (rgActions->ItemIndex == 1)
    TryEncodeDateMonthWeek(StrToInt(edYear->Text),StrToInt(edMonth->Text),
      StrToInt(edWeekMonth->Text),StrToInt(edDayWeek->Text),DateTime);
  if (rgActions->ItemIndex == 2)
    TryEncodeDateWeek(StrToInt(edYear->Text),StrToInt(edWeekYear->Text),
      DateTime,StrToInt(edDayWeek->Text));
  if (rgActions->ItemIndex == 3)
    TryEncodeDayOfWeekInMonth(StrToInt(edYear->Text),StrToInt(edMonth->Text),
	  StrToInt(edDayWeekMonth->Text),StrToInt(edDayWeek->Text),DateTime);
  if (rgActions->ItemIndex == 4)
    TryRecodeDateTime(DateTime,StrToInt(edYear2->Text),StrToInt(edMonth2->Text),
      StrToInt(edDay->Text),StrToInt(edHour->Text),StrToInt(edMinute->Text),
      StrToInt(edSecond->Text),StrToInt(edMilliSecond->Text),DateTime);
  edDateTime->Text = DateTimeToStr(DateTime);
}

Uses

Personal tools