C++ Builder 參考手冊(cè) ? System::Dateutils ? EndOfAWeek
某一年的某一周的結(jié)束時(shí)間 (ISO 8601)负芋,
這一年的這一周星期日 23:59:59.999 或這周指定的星期幾的結(jié)束時(shí)間 23:59:59.999
頭文件:#include <System.DateUtils.hpp>
命名空間:System::Dateutils
函數(shù)原型:
System::TDateTime __fastcall EndOfAWeek(
const System::Word AYear,
const System::Word AWeekOfYear,
const System::Word ADayOfWeek = 7);
參數(shù):
- AYear:年雪位,1 - 9999;
- AWeekOfYear:這一年的第幾周峻凫,1 - 53娜遵;
- ADayOfWeek:這一周的星期幾伯顶,默認(rèn)值 7莉撇;1 = 星期一害晦,2 = 星期二特铝,……7 = 星期日;
返回值:
- AYear 年的第 AWeekOfYear 周的星期 ADayOfWeek 的結(jié)束時(shí)間壹瘟,這一天的 23:59:59.999鲫剿;
? 這個(gè)函數(shù)使用 ISO 8601 國(guó)際標(biāo)準(zhǔn) (中國(guó)使用這個(gè)標(biāo)準(zhǔn));
? 一年有多少周請(qǐng)參考 WeeksInYear 或 WeeksInAYear稻轨;周的規(guī)則請(qǐng)參考 IsValidDateWeek 和 IsValidDateMonthWeek灵莲;
? 獲取某個(gè)日期時(shí)間是這一年的第幾周可以使用函數(shù) WeekOf 或 WeekOfTheYear; - 比較函數(shù) EndOfAWeek 和 EndOfTheWeek:
? EndOfAWeek 的參數(shù)是整數(shù)年殴俱、第幾周笆呆、星期幾;這個(gè)函數(shù)可以獲取這一周每一天的結(jié)束時(shí)間粱挡,不限于星期日赠幕;
? EndOfTheWeek 的參數(shù)是日期時(shí)間,這個(gè)函數(shù)只獲取這一周星期日的結(jié)束時(shí)間询筏。
例:
#include <System.DateUtils.hpp>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TDateTime dt = Sysutils::Now();
Memo1->Lines->Add(L"現(xiàn)在時(shí)間 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", dt));
Memo1->Lines->Add(L"本周開(kāi)始 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfTheWeek(dt)));
Memo1->Lines->Add(L"本周結(jié)束 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfTheWeek(dt)));
unsigned short iYear = Dateutils::YearOf(dt);
unsigned short iWeek = Dateutils::WeekOf(dt);
Memo1->Lines->Add(String().sprintf(L"今天是 %d年 的 第%d周", iYear, iWeek));
Memo1->Lines->Add(L"本周開(kāi)始 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfAWeek(iYear,iWeek)));
Memo1->Lines->Add(L"本周結(jié)束 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfAWeek(iYear,iWeek)));
Memo1->Lines->Add(L"本周二開(kāi)始 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfAWeek(iYear,iWeek,2)));
Memo1->Lines->Add(L"本周二結(jié)束 " + FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfAWeek(iYear,iWeek,2)));
}
運(yùn)行結(jié)果:
相關(guān):
- 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 參考手冊(cè) ? System::Dateutils ? EndOfAWeek