StartOfTheWeek - C++ Builder

C++ Builder 参考手册 ➙ System::Dateutils ➙ StartOfTheWeek


这个日期时间所在周的开始时间 (ISO 8601),这周的星期一 00:00:00.000

头文件:#include
命名空间:System::Dateutils
函数原型:

System::TDateTime __fastcall StartOfTheWeek(const System::TDateTime AValue);

参数:

  • AValue:日期时间;

返回值:

  • 这个日期时间所在周的开始时间 (ISO 8601),这周的星期一 00:00:00.000;
  • 按照 ISO 8601 国际标准 (中国使用这个标准),每周星期一为第一天,星期日为最后一天,详细描述请参考 IsValidDateWeek;
  • 比较函数 StartOfAWeek 和 StartOfTheWeek:
    • StartOfAWeek 的参数是整数年、第几周、星期几;这个函数可以获取这一周每一天的开始时间,不限于星期一;
    • StartOfTheWeek 的参数是日期时间,这个函数只获取这一周星期一的开始时间。

例:

#include 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    TDateTime dt = Sysutils::Now();
    Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", dt));
    Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfTheWeek(dt)));
    Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfTheWeek(dt)));
}

运行结果:


相关:

  • 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::StartOfADay
  • System::Dateutils::EndOfADay
  • System::Dateutils::DaysInYear
  • System::Dateutils::DaysInAYear
  • System::Dateutils::DaysInMonth
  • System::Dateutils::DaysInAMonth
  • System::Dateutils::WeeksInYear
  • System::Dateutils::WeeksInAYear
  • System::Dateutils

C++ Builder 参考手册 ➙ System::Dateutils ➙ StartOfTheWeek

你可能感兴趣的:(StartOfTheWeek - C++ Builder)