C++ Builder 參考手冊 ? System::Dateutils ? StartOfADay
某一年的某一天的開始時間俊扭,
這一年的第幾天的開始時間 (00:00:00.000)扭勉,
這個年舆驶、月绞愚、日的開始時間 (00:00:00.000)
頭文件:#include <System.DateUtils.hpp>
命名空間:System::Dateutils
函數(shù)原型:
System::TDateTime __fastcall StartOfADay(
const System::Word AYear,
const System::Word ADayOfYear);
System::TDateTime __fastcall StartOfADay(
const System::Word AYear,
const System::Word AMonth,
const System::Word ADay);
參數(shù):
- AYear:年花枫,1 - 9999庆锦;
- AMonth:月上忍,1 - 12腊状;
- ADay:日携御,1 - 31昌粤;
- ADayOfYear:這一年的幾天既绕,1 - 366;
返回值:
- AYear 年的第 ADayOfYear 天的開始時間 (00:00:00.000) 或
AYear 年 AMonth 月 ADay 日的開始時間 (00:00:00.000)涮坐; - 可以使用 DayOfTheYear 獲取一個日期時間是這一年的第幾天凄贩;
使用 StartOfADay 和 EndOfADay 獲取這一年的第幾天的日期和時間; -
StartOfTheDay 和 StartOfADay 的區(qū)別:
? StartOfTheDay 的參數(shù)是一個日期時間袱讹;
? StartOfADay 的參數(shù)是年疲扎、月、日 或年和這一年的第幾天廓译;
如果日期相同评肆,這兩個函數(shù)的返回值相同。
例:
#include <System.DateUtils.hpp>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TDateTime dt = Sysutils::Now();
Memo1->Lines->Add(L"現(xiàn)在時間 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", dt));
Memo1->Lines->Add(L"今天開始 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfTheDay(dt)));
Memo1->Lines->Add(L"今天結(jié)束 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfTheDay(dt)));
unsigned short iYear = Dateutils::YearOf(dt);
unsigned short iDoY = Dateutils::DayOfTheYear(dt);
Memo1->Lines->Add(String().sprintf(L"今天是 %d年 的 第%d天", iYear, iDoY));
Memo1->Lines->Add(L"今天開始 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfADay(iYear, iDoY)));
Memo1->Lines->Add(L"今天結(jié)束 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfADay(iYear, iDoY)));
unsigned short iMonth = Dateutils::MonthOf(dt);
unsigned short iDay = Dateutils::DayOf(dt);
Memo1->Lines->Add(String().sprintf(L"今天是 %d年%d月%d日", iYear, iMonth, iDay));
Memo1->Lines->Add(L"今天開始 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfADay(iYear, iMonth, iDay)));
Memo1->Lines->Add(L"今天結(jié)束 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfADay(iYear, iMonth, iDay)));
}
運(yùn)行結(jié)果:
相關(guān):
- System::Dateutils::DayOfTheYear
- System::Dateutils::StartOfTheYear
- System::Dateutils::EndOfTheYear
- System::Dateutils::StartOfTheMonth
- System::Dateutils::EndOfTheMonth
- System::Dateutils::StartOfTheWeek
- System::Dateutils::EndOfTheWeek
- System::Dateutils::StartOfTheDay
- System::Dateutils::EndOfTheDay
- System::Dateutils::StartOfAYear
- System::Dateutils::EndOfAYear
- System::Dateutils::StartOfAMonth
- System::Dateutils::EndOfAMonth
- System::Dateutils::StartOfAWeek
- System::Dateutils::EndOfAWeek
- System::Dateutils::StartOfADay
- System::Dateutils::EndOfADay
- System::Dateutils::DaysInYear
- System::Dateutils::DaysInAYear
- System::Dateutils::DaysInMonth
- System::Dateutils::DaysInAMonth
- System::Dateutils::WeeksInYear
- System::Dateutils::WeeksInAYear
- System::Dateutils::WeekOf
- System::Dateutils::WeekOfTheYear
- System::Dateutils
C++ Builder 參考手冊 ? System::Dateutils ? StartOfADay