DTStartEnd (C++)
Description
This example demonstrates the use of some routines in the DateUtils unit.
Code
TDateTime DateTime;
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
DateTime = Date() + Time();
/* Verify whether the time portion of the TDateTime variable occurs after noon. */
if (IsPM(DateTime))
ShowMessage("It is after-noon");
else
ShowMessage("It is morning");
/* Write the start and the end of current date. */
Edit1->Text = DateTimeToStr(DateTime);
Memo1->Lines->Add("Start of the year: " + DateTimeToStr(StartOfTheYear(DateTime)));
Memo1->Lines->Add("Start of the month: " + DateTimeToStr(StartOfTheMonth(DateTime)));
Memo1->Lines->Add("Start of the week: " + DateTimeToStr(StartOfTheWeek(DateTime)));
Memo1->Lines->Add("Start of the day: " + DateTimeToStr(StartOfTheDay(DateTime)));
Memo1->Lines->Add("Start of a year: " + DateTimeToStr(StartOfAYear(YearOf(DateTime))));
Memo1->Lines->Add("Start of a month: " + DateTimeToStr(StartOfAMonth(YearOf(DateTime),MonthOf(DateTime))));
Memo1->Lines->Add("Start of a week: " + DateTimeToStr(StartOfAWeek(YearOf(DateTime),WeekOf(DateTime))));
Memo1->Lines->Add("Start of a day: " + DateTimeToStr(StartOfADay(YearOf(DateTime),DayOf(DateTime))));
Memo1->Lines->Add("End of the year: " + DateTimeToStr(EndOfTheYear(DateTime)));
Memo1->Lines->Add("End of the month: " + DateTimeToStr(EndOfTheMonth(DateTime)));
Memo1->Lines->Add("End of the week: " + DateTimeToStr(EndOfTheWeek(DateTime)));
Memo1->Lines->Add("End of the day: " + DateTimeToStr(EndOfTheDay(DateTime)));
Memo1->Lines->Add("End of a year: " + DateTimeToStr(EndOfAYear(YearOf(DateTime))));
Memo1->Lines->Add("End of a month: " + DateTimeToStr(EndOfAMonth(YearOf(DateTime),MonthOf(DateTime))));
Memo1->Lines->Add("End of a week: " + DateTimeToStr(EndOfAWeek(YearOf(DateTime),WeekOf(DateTime))));
Memo1->Lines->Add("End of a day: " + DateTimeToStr(EndOfADay(YearOf(DateTime),DayOf(DateTime))));
}
void __fastcall TMainForm::btProcessClick(TObject *Sender)
{
Integer number;
Memo1->Lines->Clear();
number = StrToInt(edInc->Text);
/* Increase a specific portion of the TDateTime variable. */
if (RadioGroup1->ItemIndex == 0)
DateTime = IncMilliSecond(DateTime,number);
if (RadioGroup1->ItemIndex == 1)
DateTime = IncSecond(DateTime,number);
if (RadioGroup1->ItemIndex == 2)
DateTime = IncMinute(DateTime,number);
if (RadioGroup1->ItemIndex == 3)
DateTime = IncHour(DateTime,number);
if (RadioGroup1->ItemIndex == 4)
DateTime = IncDay(DateTime,number);
if (RadioGroup1->ItemIndex == 5)
DateTime = IncMonth(DateTime,number);
if (RadioGroup1->ItemIndex == 6)
DateTime = IncYear(DateTime,number);
Edit1->Text = DateTimeToStr(DateTime);
}
Uses
- System.DateUtils.EndOfADay ( fr | de | ja )
- System.DateUtils.EndOfAMonth ( fr | de | ja )
- System.DateUtils.EndOfAWeek ( fr | de | ja )
- System.DateUtils.EndOfAYear ( fr | de | ja )
- System.DateUtils.EndOfTheDay ( fr | de | ja )
- System.DateUtils.EndOfTheMonth ( fr | de | ja )
- System.DateUtils.EndOfTheWeek ( fr | de | ja )
- System.DateUtils.EndOfTheYear ( fr | de | ja )
- System.DateUtils.IncDay ( fr | de | ja )
- System.DateUtils.IncHour ( fr | de | ja )
- System.DateUtils.IncMilliSecond ( fr | de | ja )
- System.DateUtils.IncMinute ( fr | de | ja )
- System.DateUtils.IncSecond ( fr | de | ja )
- System.DateUtils.IncWeek ( fr | de | ja )
- System.DateUtils.IncYear ( fr | de | ja )
- System.DateUtils.IsPM ( fr | de | ja )
- System.DateUtils.StartOfADay ( fr | de | ja )
- System.DateUtils.StartOfAMonth ( fr | de | ja )
- System.DateUtils.StartOfAWeek ( fr | de | ja )
- System.DateUtils.StartOfAYear ( fr | de | ja )
- System.DateUtils.StartOfTheDay ( fr | de | ja )
- System.DateUtils.StartOfTheMonth ( fr | de | ja )
- System.DateUtils.StartOfTheWeek ( fr | de | ja )
- System.DateUtils.StartOfTheYear ( fr | de | ja )